We're integrating Google api C# SDK to our application and following Google "web application" workflow. We need to retrieve currently authenticated Google user email.
We get it works using one of these approaches:
Directly make http request to https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=xxx .
Use Google people api C# sdk
var peopleService = new PeopleServiceService(new BaseClientService.Initializer { HttpClientInitializer = result.Credential, ApplicationName = "Test App" });
var peopleRequest = peopleService.People.Get("people/me");
peopleRequest.RequestMaskIncludeField = new List<string> { "person.EmailAddresses" };
var profile = peopleRequest.Execute();
- Use Google Gmail api C# sdk
var gmailService = new Google.Apis.Gmail.v1.GmailService(new BaseClientService.Initializer
{
HttpClientInitializer = result.Credential, ApplicationName = "Test App"
});
var gmailProfile = gmailService.Users.GetProfile("me").Execute();
var userGmailEmail = gmailProfile.EmailAddress;
Scopes we're using are:
"https://www.googleapis.com/auth/gmail.readonly" "email" "profile"
Examples above work well, however we don't want to use https://www.googleapis.com/auth/gmail.readonly as it's "restricted" scope.
So, we wonder if there any chance to call the Google profile email using some method from C# SDK ?
Thanks in advance, Evgeny.