简体   繁体   中英

Google+ API auto login users that have already been authenticated

有人可以将我重定向到一个网站,或告诉我如何自动登录已经通过其Google帐户验证了我的应用程序的用户。

Google+ Sign-In automatically signs in users on subsequent visits after the initially authorize your app as long as your scopes (permissions) haven't changed. This works on all the clients that Google+ Sign-In is offered for: web, Android, and iOS.

On subsequent visits, the sign in automatically calls your function that you defined for the data-callback parameter and you can immediately use the authorization info that is passed to that parameter, such as the access tokens.

If you need offline access, which based on your PHP tag you might, you should also check out the Google+ Sign-In server-side flow , which is very similar with your front-end code and callback; however, you also get a "one-time code" that you can send to your server. This one-time code can be used to securely allow your server to get its own access tokens and refresh tokens.

Also see the PHP quickstart , which demonstrates exactly how to do this scenario and includes best practices for the one-time code exchange.

I've found a post, with an answer, on stackoverflow that sounds very close to your own question, check it out:

How to automate login to Google API to get OAuth 2.0 token to access known user account

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM