JJ Pell
JJ Pell

Reputation: 941

Do I need to send google oauth access token and id token to my backend server?

I have a SPA and a backend API service. The google user signs in to the SPA at which point I obtain their access token & id token.

The backend service uses google identity to authenticate users of it using the id token. However one of the the backend services features needs to request data from the google analytics API which requires the users access token.

In this senario do I send both the id token and access token to my back end service?

Upvotes: 4

Views: 2262

Answers (1)

Michal Trojanowski
Michal Trojanowski

Reputation: 12322

Yes, in this scenario you could send the access token to your backend service so that it can contact Google's API. In most cases, access tokens are used as bearer tokens, which means that any client in possession of that token can use it to call the API. That's why you can pass a token issued to the SPA to a backend service and still be able to call Google's API.

At the same time, you should think of security implications. You should not send the access token to any services that you're not in control of. Meaning, you should not send the access token to service XYZ because that service needs it to call Google's API with a user's token if service XYZ is not under your control.

Upvotes: 6

Related Questions