Trying to OAuth to Twitter and return back to http://Localhost:port

i'm trying to OAuth to Twitter and it then returns back to our localhost:port (eg. http://localhost:6969).

I'm also trying to use Linq2Twitter. When I try and setup my application in Twitter, it's not allowing me to set the

  • Application Website.
  • Website.
  • Callback URL.
  • to be http://localhost:6969

    So, how can i make twitter OAuth against my localhost development machine?

    EDIT: I'm secretly hoping AArnott will find/read this post :)

    EDIT 2:

    Now that Andrew posted his thoughts, I'm adding some more info to get some more clarification of this reply.

    So if this is the sample code (not mine btw, but some hire'd gun, here at work) to redirect to the SP (which is Twitter, in this case...)

    public void StartOAuthAuthorize()
    {
        string link = twitterContext.GetAuthorizationPageLink(false, false);
        var uri = new Uri(link);
        NameValueCollection urlParams = HttpUtility.ParseQueryString(uri.Query);
        OAuthToken = urlParams["oauth_token"];
    
        HttpContext.Current.Session["twitterService"] = this;
        HttpContext.Current.Response.Redirect(link);
    }
    

    This would be the place i would hijack the callback url.... ?


    The answer may surprise you...

    Give Twitter any callback URI it permits (probably the URL you imagine using in production) for your oauth client registration page.

    When you send your OAuth unauthorized token request, you have the option to provide a callback URL at that time, which Twitter will prefer to use instead. You can supply localhost at that time and it works perfectly.

    Since you're using LinqToTwitter, which internally uses DotNetOpenAuth, there's no need to specify 'localhost' when you're issuing your request for authorization to the SP. DotNetOpenAuth automatically sees that you're on localhost and sends that callback URI.

    Update : And be sure you're running the latest version of LinqToTwitter (at least changeset 56159... more recent than release v1.11). Otherwise you're using OAuth 1.0, and Twitter ignores the callback URL sent in the authorization request for OAuth 1.0 clients.


    even me to was getting 401 error.. but its resolved.. during registering your application to twitter you need to give callback url... like http://localhost:8080.

    i have done this using java... so my code is: String CallbackURL="http://localhost:8080/tweetproj/index.jsp"; provider.retrieveRequestToken(consumer,CallbackURL);

    where tweetproj is my project name and index.jsp is just one jsp page...

    Hope this may helps u...

    链接地址: http://www.djcxy.com/p/42894.html

    上一篇: 如何在JSP中转储变量?

    下一篇: 尝试将OAuth转换为Twitter并返回到http:// Localhost:port