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
3
votes
1 answer

Generate JWT token signed with RSA key in python

I am trying to convert this java code for generating JWT token in python. String privateKeyContent = privateKey .replaceAll(Definitions.ApiGeneral.LINE_BREAKER, "") .replace(Definitions.AuthProperty.PRIVATE_KEY_START, "") …
student
  • 39
  • 1
  • 7
3
votes
0 answers

Receiving "TypeError: sign() missing 1 required positional argument: 'algorithm'" with python PyJWT

So I used the command: ssh-keygen -m PKCS8 -t dsa to generate the following (example) key: -----BEGIN PRIVATE…
waltcobb
  • 31
  • 1
3
votes
1 answer

Decode Firebase JWT in Python using PyJWT

I have written the following code : def check_token(token): response = requests.get("https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com") key_list = response.json() decoded_token = jwt.decode(token,…
Tom3652
  • 2,540
  • 3
  • 19
  • 45
3
votes
0 answers

How to compress the customclaims in jwt python

We are using the jwt and our custom claims have grown long and getting exceptions with ngnix server about the header size So looking to see if we could compress the custom claims and use it (We can't remove the contents to minimize the size of jwt)…
user2359997
  • 561
  • 1
  • 16
  • 40
3
votes
1 answer

A JSON web token could not be decoded

I'm attempting to port the GitHub Apps sample starter code from Ruby to Python, but I'm running into trouble whilst generating the required JWT. The Ruby script looks like this, and works fine: require 'openssl' require 'jwt' #…
cjm
  • 814
  • 1
  • 11
  • 26
3
votes
0 answers

Authenticating Google API with a service account using Python Oauthlib

I do not want to use Google APIs Client Library for Python, but still want to access Google API in Python using Oauthlib. After creating a service account in Google developer console, I downloaded the json file with the information to authenticate…
Antoine Brunel
  • 1,065
  • 2
  • 14
  • 30
2
votes
1 answer

How to use @token_required decorator for PyJWT in Flask App to access route after user gets logged in?

I've used PyJWT for authenticating the user now my main concern is how to use authentication decorator in API endpoints as I've addes SQL query to to fetch user detail using uid in my route but in token_required definition for current user do I've…
R P
  • 41
  • 5
2
votes
1 answer

Using a pyJWT expiration time

I'm working on a small project. I have a teacher's decorator. With the JWTs I produce on the login page, it is allowed to enter different roots. I want to generate JWTs with an expiration time. But there is a problem I can see the expiration time in…
Quiblord
  • 33
  • 1
  • 4
2
votes
0 answers

How to refresh token and burn token in logout In FastAPI?

I use this code for authentication. #1. auth_handler.py import time from decouple import config import jwt JWT_SECRET = config("JWT_SECRET") JWT_ALGORITHM = config("JWT_ALGORITHM") def response_token(token: str) -> dict: """ …
AliAryaie
  • 107
  • 1
  • 8
2
votes
0 answers

Encode jwt with a p12 file, or a .key extracted from said p12

I have a my_key.p12 file, password-protected. I extracted the key with openssl pkcs12 -in my_key.p12 -out my_key.key -nocerts -nodes -passin pass: Now I'm trying to sign a JWT with python using pyjwt, but no matter what I try I get…
Some Guy
  • 576
  • 1
  • 4
  • 17
2
votes
1 answer

Decode Apple's id_token (Signin) using pyJWT and Python

How do I, in Python, decode the id_token that Apple sends during the signup process? I have tried (from here https://stackoverflow.com/a/65909432/984003) import jwt decoded = jwt.decode(token, options={"verify_signature": False}) I get an…
user984003
  • 28,050
  • 64
  • 189
  • 285
2
votes
2 answers

Using python, Decode client side token fetched by microsoft teams and given to tab inside teams

I am trying to learn tab SSO. When Microsoft teams fetch token from AAD and pass it to tab, I want to send that token to my application server using ajax and decode it at server end. I can see client side token successfully decoded by manually copy…
2
votes
1 answer

module 'jwt' has no attribute 'ExpiredSignature'

I have been developing a Django application using graphene/graphql running over AWS using Docker alpine image. I have been using django-grapql-jwt-0.3.1 module for calling jwt-2.0.0 authentication in my application. Where it is calling…
2
votes
1 answer

pyjwt[crypto] 2.0.0 update incompatible with django-allauth

I have a project that uses django-allauth 0.44.0. Yesterday (12/22/20) pyjwt update your version to 2.0.0. When I try to install my dependencies running pip, return this error message, using docker-compose: Collecting pyjwt[crypto]>=1.7 ERROR: In…
2
votes
0 answers

Is there a way to parse the AST from GraphQLString using Graphene/GraphQL

I'm looking to write a custom middleware for my GraphQL endpoint using PyJWT. The problem is that I don't want to protect my login mutation. So I'm trying to write the Middleware to exclude the login mutation. This was easy to do by writing a…
brandonbanks
  • 1,125
  • 1
  • 14
  • 21