2011-01-10 183 views
0

我有點困惑如何使用Google OAuth。從我的理解,這個過程是這樣的:Google OAuth - 如何重用訪問令牌

  1. Get請求令牌
  2. 授權令牌
  3. 獲得訪問令牌

我可以做所有這些步驟已成功與PHP庫「oauth- PHP的」。但是,我無法弄清楚如何重新使用在第三步中檢索到的訪問令牌!

注意:我正在使用oauth-php的「Session」存儲。有一個「mysql」存儲選項,但我不能使用這個,因爲我的DBA對mysql的東西非常嚴格。

我已經試過這個代碼(我認爲是合理的),但無濟於事:

   $this->_store->addServerToken(
       $this->_oauthOptions['consumer_key'], // our consumer key 
       'access', // the request token's type 
       $accessToken, // the request token 
       '', // token secret - is blank (we're using OpenID + OAuth) 
       0 
      ); 
+0

更好的辦法是使用[google-api-php-client](http://stackoverflow.com/questions/23034056/get-user-information-from-google-oauth-php-api/37068291#37068291 ) 圖書館 – 2016-05-06 10:18:12

回答

1

我固定代碼..我的OAuth的一些誤解,並沒有意識到我需要兩訪問令牌和祕密。它的工作現在很棒!