Using Google OAuth to access it’s API (Nodejs)

Terence Tsang
Sep 23, 2021

Simple flow on how to get OAuth token

Reference

Create OAuth 2.0 Client ID

Google Cloud > APIs & Services > Credentials > Create OAuth Client ID

Add http://localhost:3000/oauth2callback into Authorized redirect URIs

You will then get a client id and secret

Use the following sample code to grab the access token

If you are seeing setting admin_policy_enforced error, you need to add your client id into your Google Admin (https://admin.google.com/ac/owl/list?tab=apps)

--

--