oauthlib.oauth2.rfc6749.errors.UnsupportedGrantTypeError:(unsupported_grant_type)无效的grant_type:密码

时间:2019-02-26 08:02:46

标签: python oauth-2.0 google-oauth2

我使用的是与document中提到的相同的代码,但是它不起作用

代码

oauth = OAuth2Session(client=LegacyApplicationClient(client_id=client_id))
token = oauth.fetch_token(token_url=token_url,
        username=username, password=password, client_id=client_id,
        client_secret=client_secret)

错误

Traceback (most recent call last):
  File "test.py", line 17, in <module>
    client_secret=client_secret)
  File "/home/pd/imapEnv/lib/python3.5/site-packages/requests_oauthlib/oauth2_session.py", line 307, in fetch_token
    self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/home/pd/imapEnv/lib/python3.5/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 415, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/home/pd/imapEnv/lib/python3.5/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 425, in parse_token_response
    validate_token_parameters(params)
  File "/home/pd/imapEnv/lib/python3.5/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 432, in validate_token_parameters
    raise_from_error(params.get('error'), params)
  File "/home/pd/imapEnv/lib/python3.5/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 405, in raise_from_error
    raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.UnsupportedGrantTypeError: (unsupported_grant_type) Invalid grant_type: password

0 个答案:

没有答案