Usuário com melhor resposta
google Calendar Api em Azure

Pergunta
-
How to activate google calendar API on azure without Active Directory?
i have this code running on local host:
using PagedList;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Turismo.Models;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Services;
using Google.Apis.Util.Store;// GET: Events
[AllowAnonymous]
public ActionResult Calendar(int? Id, string Gmail) {// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/calendar-dotnet-quickstart.json
string[] Scopes = { CalendarService.Scope.Calendar };
string ApplicationName = "Google Calendar API .NET Quickstart";
var agendar = db.Events.Where(o => o.ID_Evento == Id).FirstOrDefault();UserCredential credential;
using (var stream =
new FileStream(Server.MapPath("../client_secret.json"), FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Server.MapPath("/calendar-dotnet-quickstart.json");credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
Gmail,
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}// Create Google Calendar API service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});// Define parameters of request.
EventsResource.ListRequest request = service.Events.List("primary");
request.TimeMin = DateTime.Now;
request.ShowDeleted = false;
request.SingleEvents = true;
request.MaxResults = 10;
request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;// List events.
Google.Apis.Calendar.v3.Data.Events events = request.Execute();
Console.WriteLine("Upcoming events:");
if (events.Items != null && events.Items.Count > 0)
{
foreach (var eventItem in events.Items)
{
string when = eventItem.Start.DateTime.ToString();
if (String.IsNullOrEmpty(when))
{
when = eventItem.Start.Date;
}
Console.WriteLine("{0} ({1})", eventItem.Summary, when);
}
}
else
{
Console.WriteLine("No upcoming events found.");
}Event evnt = new Event();
evnt.Summary = agendar.Título;
evnt.Location = agendar.Local;
evnt.Description = agendar.Descrição;//
EventDateTime startTime = new EventDateTime() { DateTime = new DateTime(agendar.Data_Início.Value.Year,agendar.Data_Início.Value.Month,agendar.Data_Início.Value.Day,19,00,00)};
evnt.Start = startTime;
if (agendar.Data_Fim != null)
{
EventDateTime endTime = new EventDateTime() { DateTime = new DateTime(agendar.Data_Fim.Value.Year, agendar.Data_Fim.Value.Month, agendar.Data_Fim.Value.Day, 19, 00, 00) };
evnt.End = endTime;
}
else
{
evnt.End = startTime;
}
String calendarId = "primary";
EventsResource er = new EventsResource(service);//
service.Events.Insert(evnt, calendarId).Execute();
//
return View();
}When i Deploy it to Azure i have OAUTH denied.....
can u help?
Respostas
-
Bom dia, fjuniorf. Tudo bem?
Obrigado por usar o fórum MSDN.
Esse é o fórum MSDN para perguntas em português.
Para perguntas em inglês, você deve usar o fórum em inglês.
Segue o link: https://social.msdn.microsoft.com/Forums/en-US/home
Atenciosamente,
Filipe B de Castro
Esse conteúdo é fornecido sem garantias de qualquer tipo, seja expressa ou implícita
MSDN Community Support
Por favor, lembre-se de Marcar como Resposta as postagens que resolveram o seu problema. Essa é uma maneira comum de reconhecer aqueles que o ajudaram e fazer com que seja mais fácil para os outros visitantes encontrarem a resolução mais tarde.
- Marcado como Resposta Filipe B CastroModerator segunda-feira, 15 de janeiro de 2018 18:58
-
Boa tarde,
Por falta de retorno essa thread está encerrada.
Se necessário, favor abrir uma nova thread.
Atenciosamente,Filipe B de Castro
Esse conteúdo é fornecido sem garantias de qualquer tipo, seja expressa ou implícita
MSDN Community Support
Por favor, lembre-se de Marcar como Resposta as postagens que resolveram o seu problema. Essa é uma maneira comum de reconhecer aqueles que o ajudaram e fazer com que seja mais fácil para os outros visitantes encontrarem a resolução mais tarde.
- Marcado como Resposta Filipe B CastroModerator segunda-feira, 15 de janeiro de 2018 18:58
Todas as Respostas
-
How to activate google calendar API on azure without Active Directory?
i have this code running on local host:
using PagedList;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Turismo.Models;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Services;
using Google.Apis.Util.Store;// GET: Events
[AllowAnonymous]
public ActionResult Calendar(int? Id, string Gmail) {// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/calendar-dotnet-quickstart.json
string[] Scopes = { CalendarService.Scope.Calendar };
string ApplicationName = "Google Calendar API .NET Quickstart";
var agendar = db.Events.Where(o => o.ID_Evento == Id).FirstOrDefault();UserCredential credential;
using (var stream =
new FileStream(Server.MapPath("../client_secret.json"), FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Server.MapPath("/calendar-dotnet-quickstart.json");credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
Gmail,
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}// Create Google Calendar API service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});// Define parameters of request.
EventsResource.ListRequest request = service.Events.List("primary");
request.TimeMin = DateTime.Now;
request.ShowDeleted = false;
request.SingleEvents = true;
request.MaxResults = 10;
request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;// List events.
Google.Apis.Calendar.v3.Data.Events events = request.Execute();
Console.WriteLine("Upcoming events:");
if (events.Items != null && events.Items.Count > 0)
{
foreach (var eventItem in events.Items)
{
string when = eventItem.Start.DateTime.ToString();
if (String.IsNullOrEmpty(when))
{
when = eventItem.Start.Date;
}
Console.WriteLine("{0} ({1})", eventItem.Summary, when);
}
}
else
{
Console.WriteLine("No upcoming events found.");
}Event evnt = new Event();
evnt.Summary = agendar.Título;
evnt.Location = agendar.Local;
evnt.Description = agendar.Descrição;//
EventDateTime startTime = new EventDateTime() { DateTime = new DateTime(agendar.Data_Início.Value.Year,agendar.Data_Início.Value.Month,agendar.Data_Início.Value.Day,19,00,00)};
evnt.Start = startTime;
if (agendar.Data_Fim != null)
{
EventDateTime endTime = new EventDateTime() { DateTime = new DateTime(agendar.Data_Fim.Value.Year, agendar.Data_Fim.Value.Month, agendar.Data_Fim.Value.Day, 19, 00, 00) };
evnt.End = endTime;
}
else
{
evnt.End = startTime;
}
String calendarId = "primary";
EventsResource er = new EventsResource(service);//
service.Events.Insert(evnt, calendarId).Execute();
//
return View();
}When i Deploy it to Azure i have OAUTH denied.....
can u help?
- Editado fjuniorf terça-feira, 9 de janeiro de 2018 15:45
- Mesclado Neelesh Ray -MSFTMicrosoft employee terça-feira, 9 de janeiro de 2018 20:25 Same cx|same issue
-
Bom dia, fjuniorf. Tudo bem?
Obrigado por usar o fórum MSDN.
Esse é o fórum MSDN para perguntas em português.
Para perguntas em inglês, você deve usar o fórum em inglês.
Segue o link: https://social.msdn.microsoft.com/Forums/en-US/home
Atenciosamente,
Filipe B de Castro
Esse conteúdo é fornecido sem garantias de qualquer tipo, seja expressa ou implícita
MSDN Community Support
Por favor, lembre-se de Marcar como Resposta as postagens que resolveram o seu problema. Essa é uma maneira comum de reconhecer aqueles que o ajudaram e fazer com que seja mais fácil para os outros visitantes encontrarem a resolução mais tarde.
- Marcado como Resposta Filipe B CastroModerator segunda-feira, 15 de janeiro de 2018 18:58
-
Boa tarde,
Por falta de retorno essa thread está encerrada.
Se necessário, favor abrir uma nova thread.
Atenciosamente,Filipe B de Castro
Esse conteúdo é fornecido sem garantias de qualquer tipo, seja expressa ou implícita
MSDN Community Support
Por favor, lembre-se de Marcar como Resposta as postagens que resolveram o seu problema. Essa é uma maneira comum de reconhecer aqueles que o ajudaram e fazer com que seja mais fácil para os outros visitantes encontrarem a resolução mais tarde.
- Marcado como Resposta Filipe B CastroModerator segunda-feira, 15 de janeiro de 2018 18:58