Asp MVC 5 Google Api mybusinessInformation

  Kiến thức lập trình

I try to get the reviews for an enterprise to show it on their website.

But I can’t connect, I have all ready uri redirect missmatch.

I dev with asp mvc 5, c#, I tried app.authgoogleAuth for oauth2. but doesn’t work.

in startup.auth.cs

app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
      ClientId = "xxxMyClientID",
      ClientSecret = "xxxMyclientsecret"

in my controller

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

private async Task<UserCredential> 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(
   var userId = identity.FindFirstValue(MyClaimTypes.GoogleUserId);

   var token = await dataStore.GetAsync<TokenResponse>(userId);
   return new UserCredential(flow, userId, token);

But identity is always null.

If anyone can help me.


New contributor

M.S.WebFustion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website