Twitter authentication without using pin

2019-05-03 07:36发布

I'm trying to authenticate user accounts in Windows Phone. I found this C# library for the job (tweetsharp).

Their example is pretty clear but they use a pin code to authenticate the user.

using TweetSharp;

// Pass your credentials to the service
TwitterService service = new TwitterService("consumerKey", "consumerSecret");

// Step 1 - Retrieve an OAuth Request Token
OAuthRequestToken requestToken = service.GetRequestToken();

// Step 2 - Redirect to the OAuth Authorization URL
Uri uri = service.GetAuthorizationUri(requestToken);
Process.Start(uri.ToString());

// Step 3 - Exchange the Request Token for an Access Token
string verifier = "123456"; // <-- This is input into your application by your user
OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

// Step 4 - User authenticates using the Access Token
service.AuthenticateWith(access.Token, access.TokenSecret);
IEnumerable<TwitterStatus> mentions = service.ListTweetsMentioningMe();

I was wondering if it's possible to do this without the pincode? I've tried apps that don't ask for the code. Does this mean that tweetsharp is outdated?

Any idea if I can still do the authentication with tweetsharp without using the pin part? Or are there any alternative SDK's out there for windows phone?

2条回答
神经病院院长
2楼-- · 2019-05-03 08:08

Instead of Tweetsharp, you can also make use of Hammock library to access Twitter API. Here is a blog which explains how to implement OAuth for twitter using Hammock.

Hope that helps you.

查看更多
Lonely孤独者°
3楼-- · 2019-05-03 08:21

On TweetSharp page there is also mentioned xAuth:

If you are building a mobile application and want to benefit from a seamless authentication experience with no additional steps for the user, you need to enroll your application in Twitter's xAuth support. You must complete this step in order for xAuth to function correctly.

using TweetSharp;

// OAuth Access Token Exchange
TwitterService service = new TwitterService("consumerKey", "consumerSecret");
OAuthAccessToken access = service.GetAccessTokenWithXAuth("username", "password");

Responing to your comment, another option would be using companion web application opened in WebBrowser control in your mobile application, see https://github.com/danielcrenna/tweetsharp#authenticating-a-browser-application

查看更多
登录 后发表回答