Can someone redirect me to a website or tell me how I can auto login people who have already authenticated my app from their google account.
2 Answers
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.
- 6,801
- 1
- 23
- 26
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