简体   繁体   English

对社交api身份验证进行故障排除抄写员

[英]troubleshooting scribe for social api authentication

I just started looking at scribe for authentication with social networks such as twitter/facebook etc. I am using the example for twitter as reference. 我刚刚开始研究抄写员如何使用诸如twitter / facebook等社交网络进行身份验证。我将Twitter示例用作参考。 However, I don't seem to get oauth_verifier from twitter for some reason (even though the callback is registered through the service builder - I am using localhost in the callback as it worked with another social api). 但是,由于某种原因,我似乎没有从twitter获得oauth_verifier(即使回调是通过服务生成器注册的-我在回调中使用localhost,因为它与另一个社交api一起工作)。 Any helpful suggestions would be quite welcome. 任何有用的建议都将受到欢迎。 thanks in advance. 提前致谢。

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

Debug output from scribe ( I changed the token info ): 调试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...

Update: I am able to receive the oauth_verifier now. 更新:我现在可以收到oauth_verifier。 I will update this post once I am done testing. 完成测试后,我将更新此帖子。

pilot error mostly. 飞行员错误大多。 I was able to get oauth working with twitter using scribe. 我能够使用抄写员在Twitter上使用oauth。 After getting the service, the request Token from the service & then the authorizationUrl from the service (while passing in the request token), I was able to redirect to the authorization URL. 获得服务,来自服务的请求令牌以及来自服务的authorizationUrl(在传递请求令牌的同时),我能够重定向到授权URL。 Once there, I was able to authenticate myself against twitter using my twitter ID which redirected me to the callback URL specified when I created the service. 到达那里后,我便可以使用我的Twitter ID对Twitter进行身份验证,该ID将我重定向到创建服务时指定的回调URL。 Upon authentication, I received the oauth_verifier which I was able to use to create the verifier & then receive the access token from the service using the verifier and the request token. 进行身份验证后,我收到了oauth_verifier,可以用来创建验证器,然后使用验证器和请求令牌从服务中接收访问令牌。 Then the oauth request was made & signed which resulted in the response from twitter with the user details. 然后,发出并签名了oauth请求,并导致来自Twitter的响应以及用户详细信息。 Worked. 工作了。 Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM