How do you configure Postman with a Google Service Account to use OAuth2.0?

Hi,
I have been searching for an example but having no luck, so creating a new post here.
(Apologies if an example exists already, please direct me.)

How do you configure Postman with a Google Service Account to use OAuth2.0 ?

My Google Service Account has been enabled to access specific Google API endpoints.
I was given a creds.json file with the following key / values (which works in various py scripts).

"type": "service_account",
  "project_id":  "<redacted>",
  "private_key_id": "<redacted>",
  "private_key": <redacted key here>
  "client_email": "foo@bar.com",
  "client_id": "<redacted>",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/<redacted>.com"

Unfortunately I don’t see the options to enter this type of service account info into the native OAuth2.0 Configuration Options. For instance, I don’t have a Client Secret. In this case I believe I have to pass my Private Key back to Google to Auth.

I found a post on StackOverFlow

Apparently I need to authorize with “Add authorization data to” Request Headers ? Or some other way to pass the creds…

Does anyone have an example to configure Postman with a service account like in my scenario?
Or a link to docs or a video?

Thank you in advance!

1 Like

apparently I need to use >>> OAuth 2.0 Playground

4 Likes

Awesome that you figured this out. Thanks for letting us know what worked :slight_smile: :slight_smile: and welcome to the Postman Community!

Well, that’s one way to solve this problem with the Google Play Ground tokens, but it would be nice if Postman had an option to pass the creds.json file, rather than the extra step with playground. It seems the a Google API search in Postman does not return “all the Google api” details, prolly more of a Google Fail than Postman…

How did you use your service account credentials in the playground?

Sorry , I don’t really remember exactly, only used it to test one time. IIRC, I had to setup my service account in the OAuth2 playground first… then I tested the google api… you need a token for the project, that is the key point.

I was testing a py script and needed to import >>> from google.oauth2 import service_account

from there I was able to test creds set up in the google playground

use this google auth endpoint >>>“hXXps://accounts.google.com/o/oauth2/auth”
create an environment to store creds as tokens
create a collection to save to my collections
create tokens with >>>> “hXXps://developers.google.com/oauthplayground/”

For Authorization in my Dev Google Api environment >
Type = OAuth2.0
Add auth data to Request Headers
Available Tokens
Header Prefix Bearer

To be clear I could not pass a creds.json file to the play ground… had to use a token.