Questions tagged [pyjwt]

Anything related to PyJWT library. It is JSON Web Token implementation in Python.

PyJWT is a Python library for encoding and decododing JSON Web Tokens (JWT). JWT is a compact, URL-safe means of representing claims to be transferred between two parties. It is intended for space constrained environments such as HTTP Authorization headers and URI query parameters. It is defined in industry-standard RFC 7519.

Learn more about it on PyJWT site

106 questions
1
vote
1 answer

How do I get the pem from .jks file?

I am trying to use the .jks file to sign the jwt token. The libraries I am using are pyjwt and pyjks. Below is the code snippets: userDto = user payload = { "iss": "test", "exp": datetime.now(tz=timezone.utc)…
Felix
  • 23
  • 1
  • 6
1
vote
0 answers

pyjwt encoding problems (RS256 algorithm)

I'm just start working with/learning jwt. To implement it I've decided to use PyJWT. Also I want RS256 algorithm. First of all I've just run example from documentation: https://pyjwt.readthedocs.io/en/latest/usage.html But EVEN SO I've already got…
Rumotameru
  • 111
  • 1
  • 8
1
vote
1 answer

ContextualVersionConflict Error with PyJWT on installing djangorestframework-simplejwt

I have a digital ocean django instance and after I installed djangorestframework-simplejwt, I am getting Contextual Version Conflict with following error message: (PyJWT 1.7.1 (/usr/lib/python3/dist-packages), Requirement.parse('pyjwt<3,>=2'),…
1
vote
0 answers

Signing a JWT made from a GCP service account json for IAP gives Error: "sign() missing 1 required positional argument: "algorithm"

Trying to create a signed JWT from a Service Account Key to use in GCP using the ES256 algorithm with this code: import google.auth.jwt as jwt import google.auth.crypt import time import json sa_file = 'service_account.json' iat = time.time() exp…
1
vote
0 answers

PyJWT does not decode RS256 unencrypted token, Could not deserialize key data error

I am trying to decode a JWT token. The token is signed but is not encrypted (so for instance it is decodeable by jwt.io webpage). I have the dependency in requirements.txt: PyJWT[crypto]==2.0.1. Which supposed to install both PyJWT and cryptography…
onkami
  • 8,791
  • 17
  • 90
  • 176
1
vote
1 answer

Verify the JWT token signature without decoding it in the PyJWT library

Is it possible to verify the JWT token signature without decoding it in the PyJWT library?
Helen
  • 463
  • 2
  • 9
  • 23
1
vote
3 answers

PyJWT: Custom Header - Remove type from jwt header

How can I remove the dictionary value "typ": "JWT" from jwt header? I have tried the following jwt.encode( { "iat": 1588108543, "exp": 1588112143, "ehts": "...", "edts": "...." }, privateKey, …
john
  • 2,324
  • 3
  • 20
  • 37
1
vote
1 answer

python decode JWT not containing any dots

I am given a JWT which does not contain any dots. I read somewhere that the typical format of a JWT is 3 pieces of string concatenated with 2 dots in total. Using PyJWT when I try to decode the token, I am getting the below error - Traceback (most…
Rahul Chowdhury
  • 173
  • 2
  • 11
1
vote
1 answer

How do I sign a JWT using ES256?

I am trying to sign using pyjwt key = jwk.JWK.from_pem(pkey_contents) token = jwt.JWT(header={"alg": "ES256"}, claims=Token.serialize()) token.make_encrypted_token(key) and I am getting this error app_1 | File…
wonton
  • 7,568
  • 9
  • 56
  • 93
1
vote
1 answer

How to add new file path to environment variable Path in azure app service

I am creating azure web app for web2py project, my application uses jwt package. Now I want to install pyjwt package to azure app service. After installing it through kudu it installed on some other location which is not in azure app service…
Prasad Telkikar
  • 15,207
  • 5
  • 21
  • 44
1
vote
1 answer

How can I redirect to a protected URL after login in Flask?

I am developing a web project with microservices. In the backend, I have a Login service which is responsible for checking the user credentials and returning a valid JWT. I have another service called Views which is responsible for serving the UI…
alpt
  • 61
  • 1
  • 5
1
vote
1 answer

convert APNs auth key to use with PyJWT

Context I am using pyjwt to generate a jwt to send push notifications from a python backend to APNs (Apple Push Notification service). My backend is running on a standard GAE (Google App Engine) instance, so I must use the legacy packages pycrypto…
user5791460
1
vote
1 answer

How to use JWT (JSON Web Tokens) with Django and Python for creating the REST API for signup and login

I've being trying to implement the JWT (JSON Web Tokens) in the Django project. But I was not able to achieve the same. Can you please help me with some tutorial or tips or links to study the same. I tried using the pyjwt in my project, but the…
1
vote
1 answer

How to use lists or dicts as command line arguments in pyJWT

The following python code produces a valid JWT token, using pyjwt: >>> import jwt >>> payload = {'nested': [{'name': 'me', 'id': '1'}]} >>> token = jwt.encode(payload, 'secret') >>> token.decode() ey[...]ko0Zq_k pyjwt also supports calls from the…
Arne
  • 17,706
  • 5
  • 83
  • 99
1
vote
1 answer

store jwt token into cookie in python flask restplust for login api

I have written REST API for login and logout using flask-restplus and flask_jwt_extended, I implemented jwt access_token generation that works seamlessly, but now I need to store token into cookie. my code is like this: api/user/resource.py from…
Chang Zhao
  • 631
  • 2
  • 8
  • 24