Skip to content

Instantly share code, notes, and snippets.

@hanksudo
Last active June 27, 2023 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanksudo/acfed7e7c9e63adc09e8ac0433a53508 to your computer and use it in GitHub Desktop.
Save hanksudo/acfed7e7c9e63adc09e8ac0433a53508 to your computer and use it in GitHub Desktop.
Get access token from Google OAuth2
  1. Create OAuth client ID from Google Credentials
  2. Request OAuth on browser

I use business.manage as scope here, change to yours

https://accounts.google.com/o/oauth2/auth?client_id=<CLIENT_ID>&redirect_uri=http://localhost&scope=https://www.googleapis.com/auth/business.manage&access_type=offline&response_type=code

If success, you will get a code from the url.

  1. Request Access token
curl \
-d client_id=<CLIENT_ID> \
-d client_secret=<CLIENT_SECRET> \
-d redirect_uri=http://localhost \
-d grant_type=authorization_code \
-d code=<CODE> \
https://accounts.google.com/o/oauth2/token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment