使用 postman + oauth2 访问 Google Apps Admin SDK
Using postman + oauth2 to access Google Apps Admin SDK
我正在努力让 oauth2 在 postman 和 Google Apps Admin Sdk 之间工作。我在 google 控制台中创建了一个客户端应用程序,并将授权重定向 URI 设置为 https://www.getpostman.com/oauth2/callback
,我在邮递员中的设置如下
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
这 returns 一个令牌 - xyz
- 登录后。
我用 url
中的令牌发出 GET
请求
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"
}
}
据我所知,这应该可行。我还需要在哪里登录?我做错了什么?
经过反复试验,我发现我的 url 不正确。将 key
更改为 access_token
就成功了。
请注意,请确保指定 domain
或 customer
参数,否则您将收到错误的请求错误。
我正在努力让 oauth2 在 postman 和 Google Apps Admin Sdk 之间工作。我在 google 控制台中创建了一个客户端应用程序,并将授权重定向 URI 设置为 https://www.getpostman.com/oauth2/callback
,我在邮递员中的设置如下
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
这 returns 一个令牌 - xyz
- 登录后。
我用 url
中的令牌发出GET
请求
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"
}
}
据我所知,这应该可行。我还需要在哪里登录?我做错了什么?
经过反复试验,我发现我的 url 不正确。将 key
更改为 access_token
就成功了。
请注意,请确保指定 domain
或 customer
参数,否则您将收到错误的请求错误。