2014-09-04 140 views

回答

5

使用谷歌OAuth園地:

https://developers.google.com/oauthplayground/

請求:

POST /oauth2/v3/token HTTP/1.1 
Host: www.googleapis.com 
Content-Type: application/x-www-form-urlencoded 

code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7& 
client_id=8819981768.apps.googleusercontent.com& 
client_secret={client_secret}& 
redirect_uri=https://oauth2-login-demo.appspot.com/code& 
grant_type=authorization_code 

(成功)響應:

{ 
    "access_token":"1/fFAGRNJru1FTz70BzhT3Zg", 
    "expires_in":3920, 
    "token_type":"Bearer" 
} 

我也強烈建議你閱讀的谷歌OAuth 2.0文檔 https://developers.google.com/accounts/docs/OAuth2WebServer

+21

這沒有幫助IMO,你只是有同樣的問題,因爲你不能以編程方式生成一個代碼。現在問題變成「如何獲得虛擬的Google授權代碼..​​....」。 Facebook提供了創建測試用戶的能力,並通過使用您的https://graph.facebook.com/v2.4/{app-id}/accounts/test-users來即時獲取該用戶的訪問令牌應用令牌。 – joelittlejohn 2015-08-04 16:32:39