Skip to content

MissingCodeError: (missing_code) Missing code parameter in response. #825

@dsuch

Description

@dsuch

Hello,

many thanks for creating the library.

I am at version 2.0.19, using the code below in order to implement a custom flow:

from O365 import Account

credentials = ('123', '456')
scopes = ['basic']

account = Account(credentials)
auth_url, state = account.con.get_authorization_url(requested_scopes=scopes)
account.con.request_token(authorization_url=auth_url, state=state)

I am getting the exception below (I am providing a full traceback for completeness):

Traceback (most recent call last):
  File "office1.py", line 9, in <module>
    account.con.request_token(authorization_url=auth_url, state=state)
  File "/home/dsuch/projects/zatosource-zato/3.2/code/lib/python3.8/site-packages/O365/connection.py", line 510, in request_token
    token_response = self.session.fetch_token(
  File "/home/dsuch/projects/zatosource-zato/3.2/code/lib/python3.8/site-packages/requests_oauthlib/oauth2_session.py", line 244, in fetch_token
    self._client.parse_request_uri_response(
  File "/home/dsuch/projects/zatosource-zato/3.2/code/lib/python3.8/site-packages/oauthlib/oauth2/rfc6749/clients/web_application.py", line 220, in parse_request_uri_response
    response = parse_authorization_code_response(uri, state=state)
  File "/home/dsuch/projects/zatosource-zato/3.2/code/lib/python3.8/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 284, in parse_authorization_code_response
    raise MissingCodeError("Missing code parameter in response.")
oauthlib.oauth2.rfc6749.errors.MissingCodeError: (missing_code) Missing code parameter in response.

I am not quite sure how to interpret it because there is no response yet at this point - the parse_authorization_code_response function is trying to extract a code from what is actually the authentication URL, i.e. it is doing it before the request is even sent.

I am not certain if this is what should be happening or perhaps whether I am not passing the correct parameters to account.con.request_token, although I think this is what README says to use?

Could you please help me out with that?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions