{"id":22705247,"url":"https://github.com/blockstack-packages/jsontokens-py","last_synced_at":"2025-06-26T21:36:37.875Z","repository":{"id":62572976,"uuid":"53624906","full_name":"blockstack-packages/jsontokens-py","owner":"blockstack-packages","description":"Library for signing and decoding JSON Web Tokens","archived":false,"fork":false,"pushed_at":"2017-10-05T22:19:32.000Z","size":25,"stargazers_count":9,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-06T07:20:02.763Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blockstack-packages.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-10T23:31:42.000Z","updated_at":"2021-02-25T00:34:30.000Z","dependencies_parsed_at":"2022-11-03T18:27:24.166Z","dependency_job_id":null,"html_url":"https://github.com/blockstack-packages/jsontokens-py","commit_stats":null,"previous_names":["blockstack/jsontokens-py","blockstack/jwt-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/blockstack-packages/jsontokens-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockstack-packages%2Fjsontokens-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockstack-packages%2Fjsontokens-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockstack-packages%2Fjsontokens-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockstack-packages%2Fjsontokens-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blockstack-packages","download_url":"https://codeload.github.com/blockstack-packages/jsontokens-py/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockstack-packages%2Fjsontokens-py/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260862682,"owners_count":23074162,"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":[],"created_at":"2024-12-10T09:09:48.648Z","updated_at":"2025-06-26T21:36:37.840Z","avatar_url":"https://github.com/blockstack-packages.png","language":"Python","readme":"# JSON Tokens\n\n[![CircleCI](https://img.shields.io/circleci/project/blockstack/jsontokens-py/master.svg)](https://circleci.com/gh/blockstack/jsontokens-py)\n[![PyPI](https://img.shields.io/pypi/v/jsontokens.svg)](https://pypi.python.org/pypi/jsontokens/)\n[![PyPI](https://img.shields.io/pypi/dm/jsontokens.svg)](https://pypi.python.org/pypi/jsontokens/)\n[![PyPI](https://img.shields.io/pypi/l/jsontokens.svg)](https://github.com/namesystem/jsontokens/blob/master/LICENSE)\n[![Slack](http://slack.blockstack.org/badge.svg)](http://slack.blockstack.org/)\n\n### Installation\n\n```bash\n$ pip install jsontokens\n```\n\n### Importing\n\n```python\n\u003e\u003e\u003e from jsontokens import TokenSigner, TokenVerifier, decode_token\n```\n\n### Signing Tokens\n\n```python\n\u003e\u003e\u003e token_signer = TokenSigner()\n\u003e\u003e\u003e payload = {\"issuedAt\": \"1440713414.19\"}\n\u003e\u003e\u003e token = token_signer.sign(payload, 'a5c61c6ca7b3e7e55edee68566aeab22e4da26baa285c7bd10e8d2218aa3b22901')\n\u003e\u003e\u003e print token\neyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3N1ZWRBdCI6IjE0NDA3MTM0MTQuMTkifQ.7UpSjte-bbk0CsBgC3AJyogLKu6SGzyigFgo2qZeUN6zKHaQsBlz_pFwHkPGLmiz4yvOd5gfWu8R2BwFX55okQ\n```\n\n### Decoding Tokens\n\n```python\n\u003e\u003e\u003e decoded_token = decode_token(token)\n\u003e\u003e\u003e import json\n\u003e\u003e\u003e print json.dumps(decoded_token, indent=2)\n{\n  \"header\": {\n    \"alg\": \"ES256\", \n    \"typ\": \"JWT\"\n  }, \n  \"payload\": {\n    \"issuedAt\": \"1440713414.19\"\n  }, \n  \"signature\": \"7UpSjte-bbk0CsBgC3AJyogLKu6SGzyigFgo2qZeUN6zKHaQsBlz_pFwHkPGLmiz4yvOd5gfWu8R2BwFX55okQ\"\n}\n```\n\n### Verifying Tokens\n\n```python\n\u003e\u003e\u003e token_verifier = TokenVerifier()\n\u003e\u003e\u003e token_is_valid = token_verifier.verify(token, '027d28f9951ce46538951e3697c62588a87f1f1f295de4a14fdd4c780fc52cfe69')\n\u003e\u003e\u003e print token_is_valid\nTrue\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockstack-packages%2Fjsontokens-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblockstack-packages%2Fjsontokens-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockstack-packages%2Fjsontokens-py/lists"}