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(
DefaultAuthenticationTypes.ApplicationCookie);
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.
Thanks
New contributor