Flask-OAuthlib "TypeError: the sequence index must be an integer, not 'str'"

I am using Flask-OAuthlib to install an OAuth2 server. When I access the server through the client.py script, I get the error message:

TypeError: sequence index must be integer, not 'str'

Apparently, something seems to be wrong in the resp variable, and printing results in "Invalid response from remote", which is not very useful.

Here is the relevant part of my client code :

@app.route('/authorized')
@remote.authorized_handler
def authorized(resp):
    if resp is None:
        return 'Access denied: reason=%s error=%s' % (
            request.args['error_reason'],
            request.args['error_description']
        )

    session['remote_oauth'] = (resp['access_token'], '') # error occurs here
    return jsonify(oauth_token=resp['access_token']) # and here

I understand that there is an open problem (2 actually, on the same problem), but the author is "on vacation" .... who knows how long

+3
source share
1 answer

- flask_oauthlib.client.OAuthException(RuntimeError), dict, , . , , ( ).

-oauthlib Google, , , , . flask-oauthlib.client , GET, -oauthlib Google POST.

access_token_method='POST' remote_app

remote = oauth.remote_app(
    ...
    authorize_url='http://127.0.0.1:5000/oauth/authorize',
    access_token_method='POST'
)

, .

+2

All Articles