Ryan N. Bell
Ryan N. Bell

Reputation: 85

Handling Multiple OAuth2 Tokens

I'm curious about using two APIs that both utilize OAuth2 authentication in the same application. A simple webpage as an example would work just fine in this case.

I tried to find resources to explain the use of the OAuth2 tokens and how they relate to the session. Do you have multiple tokens for multiple APIs? Can you modify a token in session so that it relates to multiple APIs? Even if you can do that, is it a good practice to do so?

I've looked at a couple of OAuth2 implementations with PHP and the GMail example, but haven't found anything to explain it as well as I'd like.

Any information or links to information would be greatly appreciated. Thanks.

Upvotes: 0

Views: 323

Answers (1)

Joanna
Joanna

Reputation: 2176

You have two options: the first is to request authorization for each API (say Drive and G+, etc), but the second option is to enhance the scope of your first request to include both.

In the G+ Platform docs, step 2 of Basic Steps explains that you are allowed to use multiple scopes in a request: https://developers.google.com/accounts/docs/OAuth2

Ideally, your user will only need to grant access one time for everything you need.

Upvotes: 3

Related Questions