TypeError: public_key() missing 1 required positional argument: 'backend'

See original GitHub issue

pyjwt is used by djangorestframework_simplejwt but I’m running into this exception in this package.

Expected Result

No exception

Actual Result

File "/home/brady/.envs/storefront-dev/lib64/python3.9/site-packages/jwt/jwks_client.py", line 59, in get_signing_key_from_jwt
    return self.get_signing_key(header.get("kid"))
  File "/home/brady/.envs/storefront-dev/lib64/python3.9/site-packages/jwt/jwks_client.py", line 41, in get_signing_key
    signing_keys = self.get_signing_keys()
  File "/home/brady/.envs/storefront-dev/lib64/python3.9/site-packages/jwt/jwks_client.py", line 28, in get_signing_keys
    jwk_set = self.get_jwk_set()
  File "/home/brady/.envs/storefront-dev/lib64/python3.9/site-packages/jwt/jwks_client.py", line 25, in get_jwk_set
    return PyJWKSet.from_dict(data)
  File "/home/brady/.envs/storefront-dev/lib64/python3.9/site-packages/jwt/api_jwk.py", line 92, in from_dict
    return PyJWKSet(keys)
  File "/home/brady/.envs/storefront-dev/lib64/python3.9/site-packages/jwt/api_jwk.py", line 87, in __init__
    self.keys.append(PyJWK(key))
  File "/home/brady/.envs/storefront-dev/lib64/python3.9/site-packages/jwt/api_jwk.py", line 52, in __init__
    self.key = self.Algorithm.from_jwk(self._jwk_data)
  File "/home/brady/.envs/storefront-dev/lib64/python3.9/site-packages/jwt/algorithms.py", line 370, in from_jwk
    return numbers.public_key()
TypeError: public_key() missing 1 required positional argument: 'backend'

When looking at jwt/algorithms.py it’s obviously not providing the backend parameter.

System Information

$ python -m jwt.help
{
  "cryptography": {
    "version": "2.9.2"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.9.6"
  },
  "platform": {
    "release": "5.13.9-200.brady.fc34.x86_64",
    "system": "Linux"
  },
  "pyjwt": {
    "version": "2.1.0"
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
bradydeancommented, Nov 28, 2022

fwiw I have cryptography==38.0.3 installed w/djangorestframework-simplejwt and I don’t have any issues. Poetry determined this version to install.

1reaction
bradydeancommented, Nov 28, 2022

It has been so long I can’t really remember. I’d assume you want cryptography>=3.4.0, that’s what is in setup.cfg now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

missing 1 required positional argument: 'backend' #31 - GitHub
Hey, it seems like you're using an old version of the cryptography dependency, where the backend parameter is required. I have updated setup.py ......
Read more >
TypeError: load_pem_private_key() missing 1 required ...
ini. while generating the JWT token, I was getting the below error. TypeError: load_pem_private_key() missing 1 required positional argument: ' ...
Read more >
“TypeError: missing 1 required positional argument” Code ...
1. Now, the load() function requires parameter loader=Loader. 2. ​. 3. If your YAML file contains just simple YAML (str, int, lists),.
Read more >
Python Crytptography "missing 1 required positional argument ...
Try creating an instance of "backend", then calling the method.
Read more >
TypeError: load_pem_private_key() missing 1 required ...
TypeError : load_pem_private_key() missing 1 required positional argument: 'backend'. Answer a question I'm trying to pull adobe analytics ...
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