开发者

Problem with Twitter app using python and django

I was creating开发者_JS百科 a twitter application with Django. I used the twitter lib from http://github.com/henriklied/django-twitter-oauth for OAuth , as specified in the twitter example pages .

But I am not too sure how to redirect user to my application home page once the authentication with twitter is over .

The code for

oauth_request = oauth.OAuthRequest.from_consumer_and_token(
    consumer, http_url=REQUEST_TOKEN_URL
)
oauth_request.sign_request(signature_method, consumer, None)
resp = fetch_response(oauth_request, connection)
token = oauth.OAuthToken.from_string(resp)
oauth_request = oauth.OAuthRequest.from_consumer_and_token(
    consumer, token=token, http_url=AUTHORIZATION_URL
)
print(oauth_request.to_url()); 
oauth_request.sign_request(signature_method, consumer, token)
return oauth_request.to_url()
response = HttpResponseRedirect(auth_url)
request.session['unauthed_token'] = token.to_string()   

I even tried passing a "oauth_callback" parameter along with "auth_url" . But after the authentication , it's not redirecting back to my application which is at "http://localhost:8000/myApp/twitter/"

Any clues ? Any pointers ?

Thanks Jijoy


The callback needs to be something like http://local.dev:8080. Twitter doesn't recognize localhost. One thing you probably need to do is go to your etc/hosts file and make sure you add the line 127.0.0.l local.dev


Check if you have enter the callback url in the details of your Twitter App in http://dev.twitter.com/apps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜