簡體   English   中英

使用PHP Pecl的OAuth 1.0a實現-自定義簽名(Fitbit)

[英]OAuth 1.0a Implementation with PHP Pecl - Custom Signature (Fitbit)

我有一個與Fitbit一起使用的OAuth實現,用於從fitbit的服務中提取數據。 但是,他們最近更新了服務,現在每當我嘗試獲取訪問令牌時,請求均失敗。

他們對新要求發表了以下聲明:

The solution is to OAuth sign the requests to <https://api.fitbit.com/oauth/request_token> and <https://api.fitbit.com/oauth/access_token> in a similar manner that all other calls to the Fitbit API are signed. 

Requests to <https://api.fitbit.com/oauth/request_token> need to be signed with your application's consumer key and secret. 
Requests to <https://api.fitbit.com/oauth/access_token> need to be signed with your application's consumer key and secret and the oauth_token and oauth_verifier received from the authorization callback. 

我正在使用PHP PECL OAuth庫處理OAuth請求。 但是我找不到一種將其他參數添加到簽名的方法。 我正在嘗試以下操作,但是我不確定這是更新OAuth簽名的正確方法:

$params['consumer_key'] = $this->consumer_key;
$params['consumer_secret'] = $this->consumer_secret;
$params['oauth_token'] = $this->oauth_token;
$params['oauth_verifier'] = $_REQUEST['oauth_verifier'];

$this->signature = $this->oauth->generateSignature('GET', $this->access_url, $params);
$this->access_token = $this->oauth->getAccessToken($this->access_url, $this->signature, $_REQUEST['oauth_verifier']);

我收到的OAuth錯誤是:

401
Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)
oauthoauth_signatureInvalid signature: FfvYDv5MSOfwcOwLZBJa0TlKS4Q=false

從上面的代碼存儲的簽名表明正確的簽名應為:

[signature] => wlfzqPs4aEkTkHfqyaO65D/RW6o=

這是調試信息的“已發送標頭”:

[headers_sent] => Authorization: OAuth oauth_session_handle="Frdnxw8oHe3BgNVi0Fy4jBXrZko%3D",
oauth_verifier="ss6nmke8elf3so66jg3auued49",
oauth_consumer_key="(my key)",
oauth_signature_method="HMAC-SHA1",
oauth_nonce="30463910852ea5cc2d04e60.71895372",
oauth_timestamp="1391090882",
oauth_version="1.0",
oauth_token="2cabd6beab341e332bdf8e522b6019ef",
oauth_signature="hULwWcQOl%2F8aYjh0YjR843iVXtA%3D"

我在文檔中找不到任何內容,該文檔解釋了如何設置OAuth簽名以用於其請求。 任何幫助將不勝感激!!!

如果您需要更多信息,請告訴我!

我發現了問題。

事實證明,我沒有保存要退回的oauth_token_secret ,而是使用了使用者密碼。

一旦更新了此過程,該過程將按預期運行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM