2016-04-19 6 views
1

マイルート例外TypeError:flow_from_clientsecretsは()と呼ばれる予想外のキーワード引数 'include_granted_scopes'

@app.route('/oauth2callback') 
    def oauth2callback(): 
     flow = client.flow_from_clientsecrets(
      'client_secrets.json', 
      scope='https://www.googleapis.com/auth/drive.metadata.readonly', 
      redirect_uri=flask.url_for('oauth2callback', _external=True), 
      include_granted_scopes=True) 
     if 'code' not in flask.request.args: 
      auth_uri = flow.step1_get_authorize_url() 
      return flask.redirect(auth_uri) 
     else: 
      auth_code = flask.request.args.get('code') 
      credentials = flow.step2_exchange(auth_code) 
      flask.session['credentials'] = credential.to_json() 
      return flask.redirect(flask.url_for('home')) 

がoauth2clientライブラリーの少なくとも現在のバージョンは」doesnの

ERROR 2016-04-19 11:10:59,804 wsgi.py:279] 
Traceback (most recent call last): 
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 267, in Handle 
    result = handler(dict(self._environ), self._StartResponse) 
    File "/Users/vinay/App-Engine/Rainbow/gaenv/flask/app.py", line 1836, in __call__ 
    return self.wsgi_app(environ, start_response) 
    File "/Users/vinay/App-Engine/Rainbow/gaenv/flask/app.py", line 1820, in wsgi_app 
    response = self.make_response(self.handle_exception(e)) 
    File "/Users/vinay/App-Engine/Rainbow/gaenv/flask/app.py", line 1403, in handle_exception 
    reraise(exc_type, exc_value, tb) 
    File "/Users/vinay/App-Engine/Rainbow/gaenv/flask/app.py", line 1817, in wsgi_app 
    response = self.full_dispatch_request() 
    File "/Users/vinay/App-Engine/Rainbow/gaenv/flask/app.py", line 1477, in full_dispatch_request 
    rv = self.handle_user_exception(e) 
    File "/Users/vinay/App-Engine/Rainbow/gaenv/flask/app.py", line 1381, in handle_user_exception 
    reraise(exc_type, exc_value, tb) 
    File "/Users/vinay/App-Engine/Rainbow/gaenv/flask/app.py", line 1475, in full_dispatch_request 
    rv = self.dispatch_request() 
    File "/Users/vinay/App-Engine/Rainbow/gaenv/flask/app.py", line 1461, in dispatch_request 
    return self.view_functions[rule.endpoint](**req.view_args) 
    File "/Users/vinay/App-Engine/Rainbow/mainsite/__init__.py", line 65, in oauth2callback 
    include_granted_scopes=True) 
    File "/Users/vinay/App-Engine/Rainbow/gaenv/oauth2client/util.py", line 135, in positional_wrapper 
    return wrapped(*args, **kwargs) 
TypeError: flow_from_clientsecrets() got an unexpected keyword argument 'include_granted_scopes' 
INFO  2016-04-19 11:10:59,881 module.py:787] default: "GET /oauth2callback HTTP/1.1" 500 - 

答えて

4

次の例外を与えましたこのinclude_granted_scopes引数をサポートしています:http://oauth2client.readthedocs.org/en/latest/source/oauth2client.client.html#oauth2client.client.flow_from_clientsecrets

You は古くなったコード/ドキュメントを使用していますが、他の人は前に同じ問題を報告しています。たとえば、https://groups.google.com/forum/#!topic/google-api-python-client/zQttW4WMUrgです。まだサポートされていない議論がまだthat referenced docにあるのがわかります。

答えを調べているうちに私が得たように、議論は段階的な承認に使用されたようです。 That outdated referenced docは、実際にはIncremental authorizationのセクションを持っています。

To avoid this complexity, you can include previously granted scopes in your authorization requests. For example:

flow = client.flow_from_clientsecrets(...) 
flow.params['include_granted_scopes'] = True 
関連する問題