DEV Community

Debajyoti Das
Debajyoti Das

Posted on

Google OAuth2 using POSTMAN

Found the following answer from StackOverflow and tried it out. Works 100%.

  • Create the OAuth 2.0 Client
    Visit https://console.cloud.google.com/apis/credentials

  • Click on CREATE CREDENTIALS

  • Select OAuth client ID

  • For Application Type choose Web Application

  • Add a name

  • Add following URI for Authorized redirect URIs
    https://oauth.pstmn.io/v1/callback

  • Click Save

  • Click on the OAuth client you just generated

  • In the Topbar click on DOWNLOAD JSON and save the file somewhere
    on your machine.

  • We will use the file later to authenticate Postman.

  • Authorize Postman via OAuth 2.0 Client

  • In the Auth tab under TYPE choose OAuth 2.0
    For values under Configuration Options enter the values found inside the client_secret_[YourClientID].json file we downloaded in step 9

  • Click on Get New Access Token
    Make sure your settings are as follows:

Image description

(In addition, multiple scope can be as follows, space-delimited: "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile")

Scope names to be found from below:
https://developers.google.com/identity/protocols/oauth2/scopes

  • Click on Request Token
    A new browser tab/window will open
    Once the browser tab opens, login via the appropriate Google account

  • Accept the consent screen
    Done
    Ignore the browser message "Not safe" etc. This will be shown until your app has been screened by Google officials. In this case it will always be shown since Postman is the app.

After accepting consent screen pass the access token as Bearer in Authorization tab in postman

Google also provides a GUI for OAuth2 authentication:
https://developers.google.com/oauthplayground/

Google's web server implementaion documentation for OAuth2:
https://developers.google.com/identity/protocols/oauth2/web-server

Top comments (1)

Collapse
 
Sloan, the sloth mascot
Comment deleted