blueFast
blueFast

Reputation: 44331

Specifiy oauth_callback URL for OAuth1 services (twitter)

I am trying to provide seamless login with twitter to my web application. For that, I need twitter to redirect to a specific URL after the user has authorized my application.

I do not want the user to be forced to copy paste a PIN to authorize the application.

According to the guidelines on "Implementing Sign in with Twitter", in Step 1, when obtaining a request_token an oauth_callback must be specified. But doing so with rauth raises an exception:

Traceback (most recent call last):
  File "/install_dir/web2py/gluon/restricted.py", line 212, in restricted
    exec ccode in environment
  File "/install_dir/web2py/applications/wavilon_portal/controllers/signup.py", line 213, in <module>
  File "/install_dir/web2py/gluon/globals.py", line 194, in <lambda>
    self._caller = lambda f: f()
  File "/install_dir/web2py/applications/wavilon_portal/controllers/signup.py", line 198, in oauth_signup
    authorized, authorize_url = oauth_service.check_authorization()
  File "/python_modules/oauth/service.py", line 230, in check_authorization
    authorize_url = self.get_authorize_url()
  File "/python_modules/oauth/service.py", line 195, in get_authorize_url
    return self.get_authorize_url_oauth1() if self.oauthver == OAUTH1_VER else self.get_authorize_url_oauth2()
  File "/python_modules/oauth/service.py", line 175, in get_authorize_url_oauth1
    request_token, request_token_secret = self.oauth_service.get_request_token(method="POST", oauth_callback=self.redirect_uri)
  File "/virtualenvs/python2.7.2/lib/python2.7/site-packages/rauth/service.py", line 212, in get_request_token
    r = self.get_raw_request_token(method=method, **kwargs)
  File "/virtualenvs/python2.7.2/lib/python2.7/site-packages/rauth/service.py", line 186, in get_raw_request_token
    return session.request(method, self.request_token_url, **kwargs)
  File "/virtualenvs/python2.7.2/lib/python2.7/site-packages/rauth/session.py", line 195, in request
    return super(OAuth1Session, self).request(method, url, **req_kwargs)
TypeError: request() got an unexpected keyword argument 'oauth_callback'

How can the redirect URI (oauth_callback) be speficied for OAuth1?

Upvotes: 1

Views: 1681

Answers (1)

maxcountryman
maxcountryman

Reputation: 1749

Rauth maintains the same API as Requests: twitter.get_request_token(..., params={'oauth_callback': 'http://example.com/callback'}).

Upvotes: 2

Related Questions