Ryan-Neal Mes
Ryan-Neal Mes

Reputation: 6263

Using postman + oauth2 to access Google Apps Admin SDK

I am struggling to get oauth2 working between postman and the Google Apps Admin Sdk. I have created a client app in the google console and set the Authorized redirect URIs to https://www.getpostman.com/oauth2/callback and my settings in postman are as follows

Auth URL          - https://accounts.google.com/o/oauth2/v2/auth
Access Token URL  - https://www.googleapis.com/oauth2/v4/token
Client Id         - some id here
Client Secrent    - some secret here
Scope             - https://www.googleapis.com/auth/admin.directory.user.readonly
Token Name        - Google
Grant Type        - Authorization Code
Request Access Token Locally - Checked

This returns a token - xyz - after logging in.

I do a GET request with the token in the url

https://www.googleapis.com/admin/directory/v1/users?key=xyz

The error I am getting is below

{
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "required",
        "message": "Login Required",
        "locationType": "header",
        "location": "Authorization"
      }
    ],
    "code": 401,
    "message": "Login Required"
  }
}

From what I have read this should work. Where else do I have to login? What am I doing wrong?

Upvotes: 2

Views: 3668

Answers (1)

Ryan-Neal Mes
Ryan-Neal Mes

Reputation: 6263

After playing around I figured out my url was incorrect. Changing key to access_token did the trick.

Just a side note, ensure you specify the domain or customer parameter otherwise you will receive a bad request error.

Upvotes: 2

Related Questions