I'm working on creating a smart home action for Google Assistant that will integrate with my REST API server, but I'm having trouble with the OAuth 2.0 step, detailed in this guide
Apparently, there are two endpoints needed:
- An authorization endpoint that returns an authorization code
- A token exchange endpoint that takes the auth code and returns access and refresh tokens
I understand the details of building these endpoints, with one exception. In the authorization code endpoint, you have to:
- Check if the user is signed in to your service. If the user isn't signed in, complete your service's sign-in or sign-up flow.
- Generate an authorization code for Google to use to access your API. The authorization code can be any string value, but it must uniquely represent the user, the client the token is for, and the code's expiration time, and it must not be guessable. You typically issue authorization codes that expire after approximately 10 minutes.
Both of these steps require that the OAuth server have information about the user, but the call to the endpoint (made by Google) only provides the following:
- client_id
- redirect_uri
- state
- scope
- response_type
- user_locale
As far as I know, none of these allow you to retrieve the user.
Is there something I'm missing here, or can I skip step 2 (signing in the user) and generate the auth code (step 3) without representing the user in the code?
I'm thinking the auth code needs to have user info so that when it is then sent to the token exchange endpoint, we can know which user to generate tokens for.