2016-05-29 90 views
1

我很努力使邮递员和Google Apps Admin Sdk之间的oauth2工作。我已经在谷歌控制台创建一个客户端应用程序,并设置授权的重新导向URI来https://www.getpostman.com/oauth2/callback和是我在邮递员的设置如下使用postman + oauth2访问Google Apps Admin SDK

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 

这将返回一个令牌 - xyz - 在登录后

我做一个GET请求与令牌的URL

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

我得到的错误是低于

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

从我读过的这个应该可以工作。我还有哪些地方需要登录?我究竟做错了什么?

回答

1

玩过后,我想出我的网址是不正确的。将key更改为access_token的确做到了。

只是旁注,请确保指定domaincustomer参数,否则您将收到错误的请求错误。

相关问题