question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

permission_denied() got an unexpected keyword argument 'code'

See original GitHub issue

Error while calling /users/me/ endpoint with no/wrong auth.

Code in question: https://github.com/sunscrapers/djoser/blob/35e5a5e75127d7270ab8f7bb13c4f7d0c0ec5a7b/djoser/views.py#L52 Code that calls it (from django-rest-framework): https://github.com/encode/django-rest-framework/blob/be87eb43b348f1f079de81329218b79814b97173/rest_framework/views.py#L333 Change that added the code parameter: https://github.com/encode/django-rest-framework/pull/7306

The only other issue I found about this was self closed: #538

Full trace:

Internal Server Error: /auth/users/me/
Traceback (most recent call last):
  File "C:\Users\Bor\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Users\Bor\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\Bor\AppData\Local\Programs\Python\Python38\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "C:\Users\Bor\AppData\Local\Programs\Python\Python38\lib\site-packages\rest_framework\viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "C:\Users\Bor\AppData\Local\Programs\Python\Python38\lib\site-packages\rest_framework\views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "C:\Users\Bor\AppData\Local\Programs\Python\Python38\lib\site-packages\rest_framework\views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "C:\Users\Bor\AppData\Local\Programs\Python\Python38\lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception
    raise exc
  File "C:\Users\Bor\AppData\Local\Programs\Python\Python38\lib\site-packages\rest_framework\views.py", line 497, in dispatch
    self.initial(request, *args, **kwargs)
  File "C:\Users\Bor\AppData\Local\Programs\Python\Python38\lib\site-packages\rest_framework\views.py", line 415, in initial
    self.check_permissions(request)
  File "C:\Users\Bor\AppData\Local\Programs\Python\Python38\lib\site-packages\rest_framework\views.py", line 333, in check_permissions
    self.permission_denied(
TypeError: permission_denied() got an unexpected keyword argument 'code'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
FairTraxxcommented, Oct 21, 2020

I found the temporary work around, apparently it’s a problem with django rest framework version 3.12.1 downgrading to drf 3.11.x will fix it.

5reactions
Jeketamcommented, Oct 3, 2020

Should djangorestframework<3.12.0 be specified in the README until the issue is fixed? 3.11.2 also worked when I tested.

Read more comments on GitHub >

github_iconTop Results From Across the Web

permission_denied() got an unexpected keyword argument ...
djnoer gives TypeError: permission_denied() got an unexpected keyword argument 'code' on get request on /users/me/.
Read more >
Error Message "Unexpected keyword argument passed to ...
TypeError: Unexpected keyword argument passed to optimizer: learning_rate. Possible Causes. Certain parameters have been renamed in Keras.
Read more >
[Solved]-djnoer gives TypeError: permission_denied() got an ...
Coding example for the question djnoer gives TypeError: permission_denied() got an unexpected keyword argument 'code' on get request on /users/me/-django.
Read more >
TypeError: __init__() got an unexpected keyword argument ...
Hi, I have followed the steps given in the chapter to set up mflix app. ... TypeError: init() got an unexpected keyword argument ......
Read more >
“TypeError: __init__() got an unexpected keyword argument ...
“TypeError : __init__() got an unexpected keyword argument 'address'” Code Answer · Browse Popular Code Answers by Language · Browse Other Code ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found