Tweetsharp authorization renders no oauth token

倾然丶 夕夏残阳落幕 提交于 2019-12-22 01:26:09

问题


I am trying to implement tweetsharp in my asp.net mvc 3 application but I am running into issues.

I have created a new twitter application with the following settings:

  • Application website: http://127.0.0.1:8545/
  • Type: browser
  • Callback URL: none
  • Access Type: read/write

I then used the sample provided on their website with a few minor changes:

public ActionResult Twitter()
{
    TwitterService service = new TwitterService("key", "secret");
    OAuthRequestToken requestToken = service.GetRequestToken("http://127.0.0.1:8545/Membership/TwitterOAuth");

    var uri = service.GetAuthorizationUri(requestToken);

    return new RedirectResult(uri.ToString(), false /*permanent*/);
}

public ActionResult TwitterOAuth(string oauth_token, string oauth_verifier)
{
    var requestToken = new OAuthRequestToken { Token = oauth_token };

    TwitterService service = new TwitterService("key", "secret");
    OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);

    service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
    TwitterUser user = service.VerifyCredentials();

    return RedirectToAction("Index", "Home");
}

Whenever I runt his code I get redirected to the following twitter URL: https://api.twitter.com/oauth/authorize?oauth_token=?

Anyone experienced this before?


EDIT

It appears that issue was with the way the application was setup. Since I did not provide a callback url, the application was automatically saved as a client and not browser application. Once I added a callback url the code worked correctly.


回答1:


It appears that issue was with the way the application was setup. Since you did not provide a callback url, the application was automatically saved as a client and not browser application. Once you added a callback url the code worked correctly.

[From you own question text]



来源:https://stackoverflow.com/questions/6333864/tweetsharp-authorization-renders-no-oauth-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!