ASP.NET MVC 5 Google Api mybusinessInformationC#

Место общения программистов C#
Anonymous
ASP.NET MVC 5 Google Api mybusinessInformation

Сообщение Anonymous »

Я пытаюсь получить отзывы о предприятии, чтобы разместить их на своем веб-сайте.
Но я не могу подключиться, у меня есть все готовые несоответствия перенаправления URI.Я разрабатываю ASP.NET MVC 5, C#, пробовал app.authgoogleAuth для OAuth2, но он не работает.
При запуске .auth.cs, у меня есть:

Код: Выделить всё

app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
ClientId = "xxxMyClientID",
ClientSecret = "xxxMyclientsecret"
});
В моем контроллере:

Код: Выделить всё

private readonly IDataStore dataStore = new FileDataStore(GoogleWebAuthorizationBroker.Folder);

private async Task GetCredentialForApiAsync()
{
var initializer = new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = new ClientSecrets
{
ClientId = "xxxMyClientId",
ClientSecret = "xxxMyClientSecret",
},
Scopes = MyRequestedScopes.Scopes,
};

var flow = new GoogleAuthorizationCodeFlow(initializer);

var identity = await HttpContext.GetOwinContext().Authentication.GetExternalIdentityAsync(
DefaultAuthenticationTypes.ApplicationCookie);

var userId = identity.FindFirstValue(MyClaimTypes.GoogleUserId);

var token = await dataStore.GetAsync(userId);
return new UserCredential(flow, userId, token);
}
Но личность всегда равна нулю.
Может ли кто-нибудь мне помочь?
Спасибо

Подробнее здесь: https://stackoverflow.com/questions/787 ... nformation

Вернуться в «C#»