Search code examples
node.jsgoogle-oauthgoogle-identity

Using OAuth 2.0 for Installed Applications


I am programming a command line tool (installedApp) that will need access to the Google Sheets of the user. For this I need to get an access token from the user.

I am following these guidelines OAuth2InstalledApp. So far I managed to get the authorization code by using the http://localhost type of redirect_uri. I specified http://localhost:7373/authorizationCode as the redirect_uri and I have a local server listening on port 7373.

But when I make the request to get the access token, I get an HTTP 400 Bad request response with a

redirect_uri_mismatch error

. When I make the request,the redirect_uri is defined as "The redirect URI you obtained from the Developers Console". Which is kind of wrong because when you create an Installed app you don't have the ability to specify a redirect uri (only with web apps). https://infinit.io/_/i48b2rM

So my question is what am I doing wrong?


Solution

  • When you create a client ID in the Google Developers Console, two redirect_uris are created for you: urn:ietf:wg:oauth:2.0:oob and http://localhost. Also you can consider urn:ietf:wg:oauth:2.0:oob:auto .The value your application uses determines how the authorization code is returned to your application. choose a redirect uri