I have a Web application that currently uses OAuth2 to authenticate users using their Google accounts. The flow is quite standard: the user logs in to Google, the web app gets a callback, retrieves the user identity and stores it in the session.
Now I need to create an accompanying Chrome extension. This extension needs to access the web app underneath, so it needs to authenticate against this app. I configured my extension using the official documentation, but during experiments, I realized this is not what I need. Since it uses the OAuth2 implicit flow, it doesn’t return a token that could be validated on the server side. This flow is suitable only for using Google APIs on the client side, which is not my use case. This documentation (and pretty much everything else I found on the Web) focuses on two possible cases:
- We want to access Google APIs on the extension side (
- We want to authenticate using an alternative OAuth2 service (
However, in my case, I’d like to authenticate users using Google accounts, but process the token on the server side of my Web app. I could use option 2 here, but it just doesn’t “feel right” to me to create my own “non-Google authentication service” that is just a wrapper over Google authentication service, only to be able to authenticate on the server side.
Is option 2 really the only way to go, or is there any simpler way?
I also saw someone recommending using the https://www.googleapis.com/oauth2/v3/tokeninfo endpoint to validate the token, but I find it hard to make sure that this is indeed an “official” and secure way of doing this.