Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

WrongTokenClass bug #97

Closed
Closed
@nsklikas

Description

@nsklikas

I stumbled onto the followin bug.
I try to run a regular code flow. When I try to exchange the authorization code with an access_token the following error is raised:

  File "/srv/venv/lib/python3.7/site-packages/oidcop/oauth2/token.py", line 407, in process_request
    _access_token, grant=True
  File "/srv/venv/lib/python3.7/site-packages/oidcop/session/manager.py", line 459, in get_session_info_by_token
    _token_info = self.token_handler.info(token_value)
  File "/srv/venv/lib/python3.7/site-packages/oidcop/token/handler.py", line 55, in info
    _handler, item_info = self.get_handler(item, order)
  File "/srv/venv/lib/python3.7/site-packages/oidcop/token/handler.py", line 75, in get_handler
    res = self.handler[typ].info(token)
  File "/srv/venv/lib/python3.7/site-packages/oidcop/token/__init__.py", line 117, in info
    raise WrongTokenClass(_res["token_class"])
oidcop.token.exception.WrongTokenClass: access_token

The bug happens because the authorization code and the access_token are created using the same class (DefaultToken).
So

def info(self, token: str) -> dict:
is called first to check if it is an authorization_code and then if it is an access_token. Both classes can decrypt the token, so
raise WrongTokenClass(_res["token_class"])
is raised.

To reproduce it you must use DefaultToken for both access token and authorization code (which is the default)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions