2016-05-29 136 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參數,否則您將收到錯誤的請求錯誤。

相關問題