2012-03-05 151 views
0

我想在ruby中驗證google api。我成功獲取了代碼參數。但我不能使用代碼params.i獲得訪問令牌想過去以下參數來獲得訪問令牌缺少必需的參數:grant_type

https://accounts.google.com/o/oauth2/token?code=4/HttxxNNyD8RU-emkYJufAM2&client_id=103xxxxxx-t8uaeuc4cexxxxxxxxv3ha1r50e.apps.googleusercontent.com&client_secret=xxxxxx&grant_type=authorization_code 

我得到了如下回應:

An error occured connecting to the server: 400 returned. 

<TITLE>Required parameter is missing: grant_type</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>Required parameter is missing: grant_type</H1> <H2>Error 400</H2> 

任何一個可以幫助我得到的accessToken

回答

1

看起來斜槓不應該在代碼參數中。如果需要,它應該是網址編碼。

0

Google共享這些密鑰的格式與示例中給出的格式相同。我不相信你的問題是因爲任何憑據。我強烈建議訪問http://www.visualab.org/index.php/using-google-rest-api-for-analytics,我保證你會沒事的。同樣不要忘記這些令牌在3600秒內過期,因此不得不重新加載用於請求新「代碼」的密鑰批准屏幕,或者按照鏈接中的指令並理解「刷新令牌」的「訪問令牌」以獲取更多代碼行。

相關問題