0

I have searched long and far for this on Google Identity documentation but my question seems to be out of it's scope (https://developers.google.com/identity/protocols/OAuth2).

This is what I have: I have an app that is using Google's PHP Client library to authenticate a user via oAuth2. My application stores the retrieved token & refresh token from a user. I am able to use this token and refresh token to pull in information from various Google API's (Drive, Calendar, Mail, etc). I am also storing a cookie in browser to keep the user logged in to the application when the user closes the browser. I have created a simple way for users to login to the application via a QR code that matches up their stored token and refresh token. After the first login they are able to simply use a badge to login to the application.

This is what I want but don't know how to do When a user logs into the application with their QR badge everything work perfectly (I am still able to pull in anything via the PHP Client Library/Google API's), however when a user goes to Gmail, Drive, or other Google service, Google is asking them to login (it's because they are not technically authenticated with accounts.google.com (only my application)). Is there a way to programmatically authenticate a user to accounts.google.com via a stored token/refresh token?

  • I think your question might be related to this one. Please take a look here http://stackoverflow.com/questions/9241213/how-to-refresh-token-with-google-api-client?rq=1 – Morfinismo Nov 24 '16 at 15:53
  • @Morfinismo Thanks for the suggestion, however I am already correctly using the long life refresh token to get a new token when the old token expires. Actually the PHP client library does this automatically. My oAuth2 authentication is working perfectly as well as refreshing access for long time use without expiring. My issue is I was to authenticate a User on the domain Accounts.google.com without having the User login with a username/password. It seems to me if I am displaying content from gmail for example, they would be able to automatically be logged into gmail. – ChristopherRose Nov 24 '16 at 15:58

1 Answers1

0

I was searching for a proper way to implement authentication of users with Google accounts into an app I'm developing. One thing led to another and I found this:

https://github.com/thephpleague/oauth2-google

They have a few implementations depending on how you may wish to implement OAuth2 (via separate repositories). I believe this directly answers your question, albeit 3.4 years later. Hopefully it will help someone else who is looking for this info.