2016-09-15 175 views
0

我想要訪問我的用戶的谷歌驅動器內容。 https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id= '+ $ scope.googledriveApi.client_id +' &範圍= '+ $ scope.googledriveApi.scopes +' & REDIRECT_URI ='+ $範圍: 我可以使用具有正確參數的谷歌驅動器用戶同意的URL我的域名兌換代碼.googledriveApi.redirect_uri谷歌驅動API無效客戶端

我正在嘗試對https://www.googleapis.com/oauth2/v4/token端點執行角度$ http請求。 請求如下:

$http({ 
    method: 'POST', 
    headers: {"Content-Type" : "application/x-www-form-urlencoded"}, 
    data: $.param({ 
     "code" : $routeParams.code, 
     "client_id" : $scope.googledriveApi.client_id, 
     "client_secret" : $scope.googledriveApi.secret, 
     "redirect_uri" : $scope.googledriveApi.redirect_uri, 
     "grant_type" : "authorization_code" 
    }), 
    url: 'https://www.googleapis.com/oauth2/v4/token' 
}) 

但是我從請求得到的迴應如下:

{ 
"error": "invalid_client", 
"error_description": "The OAuth client was not found." 
} 

有誰知道爲什麼會這樣?我嘗試更改產品名稱和客戶端ID名稱是相同的。我檢查了這個空間。我提到這個的原因是因爲這似乎是其他人提出了同樣的錯誤的問題,但是我的錯誤發生在$ http請求。

我回來了用戶許可代碼,我試圖在此請求中交換訪問令牌。這是錯誤發生時,我卡住了。

回答

0

嘗試這些:

  1. 下在OAuth同意屏幕上,在本SO thread規定確保產品名稱不符合項目名稱相同:

enter image description here

  • 嘗試在URI請求中包含授權標頭:

    標題:{'授權':'承運人'+ accessToken}