Google Oauth2 Get user information, encounter a strange problem

Source: Internet
Author: User
Tags autoload oauth
Exception Description
After I use account a login authorization, I get the information of account A and then exit.
After using another account B to access the authorization, the information obtained is still the information of account A.
However, after a period of time (unable to determine how long), and then use account B login authorization, you can obtain the information of account B, and then exit.
Then use account A login, get the information is still account B information, this is how one thing ah?

Test Address: http://www.euask.com/oauth/google.php


  Setauthconfigfile (' Client_secrets.json '); $client->setredirecturi (' http://www.euask.com/oauth/google.php '); $ Client->setscopes (Array (' Https://www.googleapis.com/auth/userinfo.email ', ' https://www.googleapis.com/auth/ Plus.login ', ' https://www.googleapis.com/auth/plus.me ');//$client->addscope (google_service_oauth2::userinfo _email); $plus = new Google_service_oauth2 ($client); if (Isset ($_request[' logout ')) {Session_unset ();}  if (isset ($_get[' code ')) {$client->authenticate ($_get[' code ');  $_session[' access_token '] = $client->getaccesstoken ();  $redirect = ' http://www.euask.com/oauth/google.php '; Header (' Location: '. Filter_var ($redirect, Filter_sanitize_url));} if (Isset ($_session[' Access_token ')) && $_session[' Access_token ']) {$client->setaccesstoken ($_session[')  Access_token ']);  $me = $plus->userinfo->get ();  $id = $me [' id '];  $name = $me [' GivenName '];  $email = $me [' email ']; $profile _image_url = $me [' picture '];} else {$auth _url = $clientCreateauthurl ();}?   >
  "; Print "Name: {$name}
"; Print "Email: {$email}
"; Print "Image: {$profile _image_url}
"; echo "Sign Out"; }?>

Reply content:

Exception description
After I use account a login authorization, I get the information of account A and then exit.
After using another account B to access the authorization, the information obtained is still the information of account A.
However, after a period of time (unable to determine how long), and then use account B login authorization, you can obtain the information of account B, and then exit.
Then use account A login, get the information is still account B information, this is how one thing ah?

Test Address: http://www.euask.com/oauth/google.php


  Setauthconfigfile (' Client_secrets.json '); $client->setredirecturi (' http://www.euask.com/oauth/google.php '); $ Client->setscopes (Array (' Https://www.googleapis.com/auth/userinfo.email ', ' https://www.googleapis.com/auth/ Plus.login ', ' https://www.googleapis.com/auth/plus.me ');//$client->addscope (google_service_oauth2::userinfo _email); $plus = new Google_service_oauth2 ($client); if (Isset ($_request[' logout ')) {Session_unset ();}  if (isset ($_get[' code ')) {$client->authenticate ($_get[' code ');  $_session[' access_token '] = $client->getaccesstoken ();  $redirect = ' http://www.euask.com/oauth/google.php '; Header (' Location: '. Filter_var ($redirect, Filter_sanitize_url));} if (Isset ($_session[' Access_token ')) && $_session[' Access_token ']) {$client->setaccesstoken ($_session[')  Access_token ']);  $me = $plus->userinfo->get ();  $id = $me [' id '];  $name = $me [' GivenName '];  $email = $me [' email ']; $profile _image_url = $me [' picture '];} else {$auth _url = $clientCreateauthurl ();}?   >
  "; Print "Name: {$name}
"; Print "Email: {$email}
"; Print "Image: {$profile _image_url}
"; echo "Sign Out"; }?>
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.