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
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 :)
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With