c# - Google+ SignIn API and emails -



c# - Google+ SignIn API and emails -

i trying utilize google+ sign-in api in asp.net using 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(); // info.email null here

as stated email field @ info null. if add together else scopes "email" or "https://www.googleapis.com/auth/plus.profile.emails.read" (reference) "invalid_scope"

leaving people:get api (reference) emails not 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(); // me.emails null

what missing here?

in scopes array you'll need add together plusservice.scope.userinfoemail in order able view email-related information.

scopes = new string[] { plusservice.scope.pluslogin, plusservice.scope.userinfoemail }

also, need declare additional scope in "data-scope" attribute of sign in button. in case,

data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email"

hope helps.

edit.: if you're using https://github.com/googleplus/gplus-quickstart-csharp/ starting point, info should this: http://pastebin.com/vjzhzyyk

c# google-plus google-api-dotnet-client

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -