I build a login button in my ios app . i have followed this documentation .
the login at my ios app work very fine. and i succeed to receive the auth object :
{accessToken="***********", refreshToken="*****", code="*******", expirationDate="2015-07-27 11:00:07 +0000"}
also i succeed to get the one time auth Code
[GPPSignIn sharedInstance].homeServerAuthorizationCode;
now what should i do. according to the document, i should send the homeServerAuthorizationCode
to my server. then exchange it with access token. but it doesn't mention how i could do that.
I found this article https://developers.google.com/identity/sign-in/web/server-side-flow but it just describe How to get access token . it doesn't show How to do that !
Also after i succeed to retrieve the token. How to call the google plus api. to retrieve user profile for example ?
First You have to install the Google client package in your project
"google/apiclient": "^2.0.0@RC"
Then from your IOS authorized array, you can find a "server_code":"**********" . From this server code you can get new authenticate result (acees_token,refresh_token,expire etc) from server side.Please go through the 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 will display a new token result array
{ "access_token": "*******************", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "***************", "id_token": "***************" }
Now you can verify the user by giving the access token in the url en point with method as GET
https://www.googleapis.com/plus/v1/people/me/?access_token=YOUR_NEW_ACCESS_TOKEN
The result will displays the authorized user profile.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.