Open
Description
Describe the bug
I input my body for /o/token/ and I get this error:
Internal Server Error: /o/token/
Traceback (most recent call last):
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\views\generic\base.py", line 104, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\utils\decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\views\decorators\csrf.py", line 56, in wrapper_view
return view_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\views\generic\base.py", line 143, in dispatch
return handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\utils\decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\views\decorators\debug.py", line 92, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2_provider\views\base.py", line 261, in post
url, headers, body, status = self.create_token_response(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2_provider\views\mixins.py", line 124, in create_token_response
return core.create_token_response(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2_provider\oauth2_backends.py", line 156, in create_token_response
headers, body, status = self.server.create_token_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauthlib\oauth2\rfc6749\endpoints\base.py", line 112, in wrapper
return f(endpoint, uri, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauthlib\oauth2\rfc6749\endpoints\token.py", line 114, in create_token_response
return grant_type_handler.create_token_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauthlib\openid\connect\core\grant_types\dispatchers.py", line 101, in create_token_response
return handler.create_token_response(request, token_handler)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauthlib\oauth2\rfc6749\grant_types\authorization_code.py", line 310, in create_token_response
token = modifier(token, token_handler, request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauthlib\openid\connect\core\grant_types\authorization_code.py", line 43, in add_id_token
return super().add_id_token(token, token_handler, request, nonce=nonce)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauthlib\openid\connect\core\grant_types\base.py", line 142, in add_id_token
token['id_token'] = self.request_validator.finalize_id_token(id_token, token, token_handler, request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2_provider\oauth2_validators.py", line 825, in finalize_id_token
claims, expiration_time = self.get_id_token_dictionary(token, token_handler, request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2_provider\oauth2_validators.py", line 806, in get_id_token_dictionary
claims = self.get_oidc_claims(token, token_handler, request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2_provider\oauth2_validators.py", line 786, in get_oidc_claims
data = self.get_claim_dict(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2_provider\oauth2_validators.py", line 768, in get_claim_dict
claims = {"sub": str(request.user.id)}
^^^^^^^^^^^^^^^
AttributeError: 'User' object has no attribute 'id'
To Reproduce
Use this to represent your user ID in models.py:
user_id = models.BigAutoField(primary_key=True)
Expected behavior
I'm expecting not to get this error.
Version
2.3.0
- I have tested with the latest published release and it's still a problem.
- I have tested with the master branch and it's still a problem.
Additional context
I believe that I temporarily fixed it on my end by editing the source code to replace .user.id
with .user.user_id