authentication - How to verify user ios sing in with google plus account ? server side -


i build login button in ios app . have followed documentation.

the login @ ios app work fine. , succeed receive auth object :

{accesstoken="***********", refreshtoken="*****", code="*******", expirationdate="2015-07-27 11:00:07 +0000"} 

also succeed 1 time auth code

[gppsignin sharedinstance].homeserverauthorizationcode; 

now should do. according document, should send homeserverauthorizationcode server. exchange access token. doesn't mention how that.

i found article https://developers.google.com/identity/sign-in/web/server-side-flow describe how access token . doesn't show how !

also after succeed retrieve token. how call google plus api. retrieve user profile example ?

first have install google client package in project

"google/apiclient": "^2.0.0@rc" 

then ios authorized array, can find "server_code":"**********" . server code can new authenticate result (acees_token,refresh_token,expire etc) server side.please go through below code

 $redirect_uri = 'http://******/gplusresponse';   $client = new google_client();  $client->setclientid('your_client_id');  $client->setclientsecret('your_client_secret');  $client->setredirecturi($redirect_uri);  $client->setaccesstype("offline");  $client->setscopes(array(      'https://www.googleapis.com/auth/plus.me',      'https://www.googleapis.com/auth/plus.stream.write'      ));   $token=$client->authenticate(your_server_code); print_r($token); 

it display new token result array

{ "access_token": "*******************", "token_type": "bearer", "expires_in": 3600, "refresh_token": "***************", "id_token": "***************" } 

now can verify user giving access token in url en point method get

https://www.googleapis.com/plus/v1/people/me/?access_token=your_new_access_token 

the result displays authorized user profile.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -