{"id":22210830,"url":"https://github.com/auth0-blog/jwts-in-python","last_synced_at":"2025-04-11T08:18:44.958Z","repository":{"id":76645225,"uuid":"377840073","full_name":"auth0-blog/jwts-in-python","owner":"auth0-blog","description":"Check out how to create and validate JWTs in Python","archived":false,"fork":false,"pushed_at":"2021-06-28T12:58:02.000Z","size":6,"stargazers_count":24,"open_issues_count":1,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T05:39:50.180Z","etag":null,"topics":["jwt","jwt-token","pyjwt"],"latest_commit_sha":null,"homepage":"https://auth0.com/blog/how-to-handle-jwt-in-python/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auth0-blog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-17T13:28:12.000Z","updated_at":"2025-02-02T12:21:51.000Z","dependencies_parsed_at":"2023-02-28T18:16:40.324Z","dependency_job_id":null,"html_url":"https://github.com/auth0-blog/jwts-in-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0-blog%2Fjwts-in-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0-blog%2Fjwts-in-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0-blog%2Fjwts-in-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0-blog%2Fjwts-in-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auth0-blog","download_url":"https://codeload.github.com/auth0-blog/jwts-in-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248360758,"owners_count":21090754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jwt","jwt-token","pyjwt"],"created_at":"2024-12-02T20:17:40.026Z","updated_at":"2025-04-11T08:18:44.939Z","avatar_url":"https://github.com/auth0-blog.png","language":null,"readme":"# Code Samples: Using PyJWT to Verify and Create JWTs\n\nThis repo contains the code used in the [\"How To Handle JWTs in Python\"](https://auth0.com/blog/how-to-handle-jwt-in-python) blog post check it out to learn how to create and verify JWTs using Python and PyJWT. ;)\n\n## Prerequisites\n\n- Python \u003e= 3.6\n\n## Setup\n\nGrab the repo and install the dependencies.\n\n```bash\ngit clone git@github.com:auth0-blog/jwts-in-python.git\ncd jwts-in-python\npython3 -m venv .env\nsource .env/bin/activate\npip install -U pip\npip install -r requirements.txt\n```\n\nYou'll also need to copy a pair of public/private SSH RSA keys into the `.ssh` folder. Currently there is a public example key in there used in the `examples/verify_jwt_rsa256_ssh.py` file but to use the `examples/create_jwt_rsa256_ssh.py` you'll need either a private key under the `.ssh` folder or to adjust the path to a preexisting folder.\n\nIn case you want to generate new keys [you'll find instructions here](https://auth0.com/blog/how-to-handle-jwt-in-python/#Generating-a-RSA-Key-Pair).\n\n## Running scripts\n\n```console\npython examples/verify_jwt_rsa256_ssh.py\n```\n\n## Scripts Description\n\n| Script | Description |\n| ------ | ----------- |\n| `examples/create_jwt_hs256.py` | Creates and prints out a JWT using the **HS256** algorithm |\n| `examples/create_jwt_rs256_ssh.py` | Creates and prints out a JWT using the **RS256** algorithm |\n| `examples/handle_expired_error_jwt.py` | Tries to decode an expired token and prints out the error elegantly when it fails |\n| `examples/verify_jwt_hs256.py` | Verifies and prints out the payload of a JWT signed with the **HS256** algorithm |\n| `examples/verify_jwt_rs256_ssh.py` | Verifies and prints out the payload of a JWT signed with the **RS256** algorithm |\n\n## Wrapping up\n\nIf you ran into any issues, reach out in the [comments of the blog post](https://auth0.com/blog/how-to-handle-jwt-in-python) or [feel free to tweet me](https://twitter.com/jesstemporal). Thanks!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0-blog%2Fjwts-in-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauth0-blog%2Fjwts-in-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0-blog%2Fjwts-in-python/lists"}