1

我正在尝试通过 twitter 为我的 Web 应用程序提供无缝登录。为此,在用户授权我的应用程序后,我需要 twitter 重定向到特定的 URL。

不希望用户被迫复制粘贴PIN来授权应用程序。

根据“使用 Twitter 实现登录”的指南Step 1,在获取request_tokenan时oauth_callback必须指定 in。但是这样做rauth会引发异常:

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'

如何oauth_callback为 OAuth1 指定重定向 URI ( )?

4

1 回答 1

2

Rauth 维护与 Requests: 相同的 API twitter.get_request_token(..., params={'oauth_callback': 'http://example.com/callback'})

于 2013-05-02T16:01:28.650 回答