簡體   English   中英

對社交api身份驗證進行故障排除抄寫員

[英]troubleshooting scribe for social api authentication

我剛剛開始研究抄寫員如何使用諸如twitter / facebook等社交網絡進行身份驗證。我將Twitter示例用作參考。 但是,由於某種原因,我似乎沒有從twitter獲得oauth_verifier(即使回調是通過服務生成器注冊的-我在回調中使用localhost,因為它與另一個社交api一起工作)。 任何有用的建議都將受到歡迎。 提前致謝。

OAuthService service = new ServiceBuilder()
.provider(TwitterApi.class)
.apiKey(consumerKey)
.apiSecret(consumerSecret)
.callback("http://localhost/oauth/twitter")
.build();

        //get the token
        Token requestToken = service.getRequestToken();

        String authUrl = service.getAuthorizationUrl(requestToken);
        Logger.info("authurl::" + authUrl); // not getting the oauth_verifier

調試scribe的輸出我更改了令牌信息 ):

setting oauth_callback to http://localhost/oauth/twitter
generating signature...
base string is: POST&http%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_callback%3Dhttp%253A%252F%252Flocalhost%252Foauth%252Ftwitter%26oauth_consumer_key%3DAAACCCV6ASDFGHJCgYBCD%26oauth_nonce%3D607134093%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1353965859%26oauth_version%3D1.0
signature is: +mSqKJIC1Q0pMEFs/gIJViF7kbg=
appended additional OAuth parameters: { oauth_callback -> http://localhost/oauth/twitter , oauth_signature -> +mSqKJIC1Q0pMEFs/gIJViF7kbg= , oauth_version -> 1.0 , oauth_nonce -> 607134093 , oauth_signature_method -> HMAC-SHA1 , oauth_consumer_key -> AAACCCV6ASDFGHJCgYBCD , oauth_timestamp -> 1353965859 }
using Http Header signature
sending request...
response status code: 200
response body: oauth_token=itJrpOP3KLeD7Ha6oy0IRr4HysFut5eAOpIlj8OmNE&oauth_token_secret=X8LmhAUpvIkfEd7t7P1lvwwobC3JJIhUabcEs0Rn5w&oauth_callback_confirmed=true
authurl::https://api.twitter.com/oauth/authorize?oauth_token=itJrpOP3KLeD7Ha6oy0IRr4HysFut5eAOpIlj8OmNE
obtaining access token from http://api.twitter.com/oauth/access_token
setting token to: Token[itJrpOP3KLeD7Ha6oy0IRr4HysFut5eAOpIlj8OmNE , X8LmhAUpvIkfEd7t7P1lvwwobC3JJIhUabcEs0Rn5w] and verifier to: org.scribe.model.Verifier@55ac8c3d
generating signature...

更新:我現在可以收到oauth_verifier。 完成測試后,我將更新此帖子。

飛行員錯誤大多。 我能夠使用抄寫員在Twitter上使用oauth。 獲得服務,來自服務的請求令牌以及來自服務的authorizationUrl(在傳遞請求令牌的同時),我能夠重定向到授權URL。 到達那里后,我便可以使用我的Twitter ID對Twitter進行身份驗證,該ID將我重定向到創建服務時指定的回調URL。 進行身份驗證后,我收到了oauth_verifier,可以用來創建驗證器,然后使用驗證器和請求令牌從服務中接收訪問令牌。 然后,發出並簽名了oauth請求,並導致來自Twitter的響應以及用戶詳細信息。 工作了。 希望能幫助到你。

暫無
暫無

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

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