Question

I'm using Python3 + Flask + OAuthlib in virtualenv to get the Twitter token and token_secret in order to start working with my application.

I'm copying the example hosted on OAuthlib twitter just replacing the url for my Flask app.

I've also tried to set the right callback url on my twitter app setting, either with the url where there is the login() function either with the url where there is the @twitter.authorized_handler but without success.

I got this errors:

File "C:\Users\\pyws\flask_ws\flask_engine\lib\site-packages\flask\app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\\pyws\flask_ws\flask_engine\lib\site-packages\flask_oauthlib\client.py", line 587, in decorated data = self.handle_oauth1_response()
File "C:\Users\\pyws\flask_ws\flask_engine\lib\site-packages\flask_oauthlib\client.py", line 526, in handle_oauth1_response _encode(self.access_token_method)
File "C:\Users\\pyws\flask_ws\flask_engine\lib\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 273, in sign
elif http_method.upper() in ('GET', 'HEAD') and has_params: AttributeError: 'NoneType' object has no attribute 'upper'`

I don't get the error :/ Thanks in advance for any help

Was it helpful?

Solution

From looking at the oauthlib source code it seems the access_token_method attribute isn't defined in the remote application. The documentation says that it defaults to 'GET', but that appears to not be working in your case.

Try adding it explicitly to your remote_app() definition.

twitter = oauth.remote_app(
    'twitter',
    consumer_key='xBeXxg9lyElUgwZT6AZ0A',
    consumer_secret='aawnSpNTOVuDCjx7HMh6uSXetjNN8zWLpZwCEU4LBrk',
    base_url='https://api.twitter.com/1.1/',
    request_token_url='https://api.twitter.com/oauth/request_token',
    access_token_url='https://api.twitter.com/oauth/access_token',
    authorize_url='https://api.twitter.com/oauth/authenticate',
    access_token_method = 'GET' # <--- add this line
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top