2014-02-28 66 views
1

我想在我的應用程序中使用Google驅動器API,這就是爲什麼我使用OAuth 2.0安裝應用程序。但我有一個問題 - 我無法獲得訪問令牌。無法獲取訪問令牌谷歌驅動器sdk

https://accounts.google.com/o/oauth2/auth? 
    scope=https://www.googleapis.com/auth/drive.file& 
    redirect_uri=[my redirect_uri from from Developers Console]& 
    response_type=code& 
    client_id=[My client ID for native application from Developers Console] 

然後我嘗試使用收到的授權碼使用以下請求獲得一個訪問令牌:起初我用下面的請求成功獲取授權碼

POST /o/oauth2/token HTTP/1.1 
    Host: accounts.google.com 
    Content-Type: application/x-www-form-urlencoded 

    code={My uthorization code}& 
    client_id=[My client Id]& 
    client_secret=[My clien secret]& 
    redirect_uri=[my redirect_uri from from Developers Console]& 
    grant_type=authorization_code 

所有時間服務器返回400你能告訴我可能是什麼問題嗎?

回答

0
  1. 跟蹤的HTTP請求
  2. 進入到OAuth2遊樂場,做同樣的
  3. 現貨的差異

這可能是因爲你沒有URL編碼的PARAMS

相關問題