I am trying to use the Google+ login API in ASP.NET with this code:
var flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer { ClientSecrets = secrets, Scopes = new string[] { PlusService.Scope.PlusLogin } }); token = flow.ExchangeCodeForTokenAsync("me", code, "postmessage", CancellationToken.None).Result; var service = new Oauth2Service(new Google.Apis.Services.BaseClientService.Initializer()); var request = service.Tokeninfo(); request.AccessToken = token.AccessToken; var info = request.Execute();
As indicated, the Email field in info is null. If I add anything else to Scopes like "email" or " https://www.googleapis.com/auth/plus.profile.emails.read " ( link ) I get "invalid_scope"
Leaving this to people: get the API ( link ) to get emails no better:
var credential = new UserCredential(flow, info.UserId, token); plusService = new PlusService(new Google.Apis.Services.BaseClientService.Initializer() { ApplicationName = "Test", HttpClientInitializer = credential }); var me = plusService.People.Get("me").Execute();
What am I missing here?
source share