DEV Community

Cover image for How to set up Postman to troubleshoot Google API
jeromesch
jeromesch

Posted on

How to set up Postman to troubleshoot Google API

FAQ:
Why are we using the Google API?

We're trying to automate the Usermanagment such as Roles in the Company, Calendar Events, Groups, Chatrooms

In which cases does it make sense to use the Google API?

In every case the Google API offers a solution (and you want to automate)

What is an Oauth 2.0 Token?

OAuth 2.0 is an authorization protocol and NOT an authentication protocol. As such, it is designed primarily as a means of granting access to a set of resources, for example, remote APIs or user’s data.

Starting off with POSTMAN

How to generate an OAuth 2.0 token:

  1. Ensure that the Google APIs are enabled
Go to the API Console.
Select a project or create a new one.
Select APIs & services
Select Library
Click the API you want to enable
Click ENABLE.
Enter fullscreen mode Exit fullscreen mode
  1. Create an OAuth 2.0 client ID
Go to Google Console 
-> API 
-> OAuth consent screen
Add `getpostman.com` to the Authorized domains.
Click Save.
Enter fullscreen mode Exit fullscreen mode
Go to Google Console 
-> API 
-> Credentials
Click 'Create credentials' 
-> OAuth client ID 
-> Web application
Enter fullscreen mode Exit fullscreen mode

Name: 'getpostman'
Authorized redirect URIs: https://www.getpostman.com/oauth2/callback
Copy the generated Client ID and Client secret fields for later use
In Postman select Authorization tab and select "OAuth 2.0" type.
Click 'Get New Access Token'

Fill the GET NEW ACCESS TOKEN form as following
Token Name: 'Google OAuth getpostman'
Grant Type: 'Authorization Code'
Callback URL: https://www.getpostman.com/oauth2/callback
Auth URL: https://accounts.google.com/o/oauth2/auth
Access Token URL: https://accounts.google.com/o/oauth2/token
Client ID: Client ID generated in the step 2 (also shown in downloadable JSON)
Client Secret: Client secret generated in the step 2 (also shown in downloadable JSON)
Scope: see the Google docs for the required OAuth scope (e.g., https://www.googleapis.com/auth/cloud-platform)
State: -
Client Authentication: "Send as Basic Auth header"
Click 'Request Token' and 'Use Token'

The generated Token is only usable for the Scope you intended it to be. If you need another Scope you might want to Request another token. Otherwise you might face access right problems.

Picture of the inserted Data in Postman

Usefull Links for API Documentations:

Discussion (0)