{"id":22009728,"url":"https://github.com/zitadel/examples-api-access-and-token-introspection","last_synced_at":"2026-02-17T23:35:56.953Z","repository":{"id":171311929,"uuid":"616449721","full_name":"zitadel/examples-api-access-and-token-introspection","owner":"zitadel","description":"Python examples for securing an API and invoking it as a service user","archived":false,"fork":false,"pushed_at":"2025-07-16T09:58:37.000Z","size":12880,"stargazers_count":18,"open_issues_count":2,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T03:31:48.173Z","etag":null,"topics":["api-client","api-rest","examples","jwt","python"],"latest_commit_sha":null,"homepage":"https://zitadel.com/","language":"Python","has_issues":false,"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/zitadel.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-03-20T12:15:17.000Z","updated_at":"2025-08-21T15:49:34.000Z","dependencies_parsed_at":"2025-07-16T17:57:58.280Z","dependency_job_id":"c9ebfa78-844b-4c6d-a2f3-ef1c1cf9b6e1","html_url":"https://github.com/zitadel/examples-api-access-and-token-introspection","commit_stats":null,"previous_names":["zitadel/examples-api-access-and-token-introspection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zitadel/examples-api-access-and-token-introspection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zitadel%2Fexamples-api-access-and-token-introspection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zitadel%2Fexamples-api-access-and-token-introspection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zitadel%2Fexamples-api-access-and-token-introspection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zitadel%2Fexamples-api-access-and-token-introspection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zitadel","download_url":"https://codeload.github.com/zitadel/examples-api-access-and-token-introspection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zitadel%2Fexamples-api-access-and-token-introspection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29562379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T21:50:49.831Z","status":"ssl_error","status_checked_at":"2026-02-17T21:46:15.313Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api-client","api-rest","examples","jwt","python"],"created_at":"2024-11-30T02:10:35.778Z","updated_at":"2026-02-17T23:35:51.927Z","avatar_url":"https://github.com/zitadel.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# api-access-and-token-introspection\n\nFind a detailed explanation of the concepts covered in these examples in this [blog post](https://zitadel.com/blog/api-access-and-introspection). \n\n## API Application:\nIf you have an API that behaves as an OAuth resource server that can be accessed by user-facing applications and need to validate an access token by calling the ZITADEL introspection API, you can use the following methods to register these APIs in ZITADEL: \n\n- [JSON Web Token (JWT) Profile (Recommended)](https://zitadel.com/docs/apis/openidoauth/authn-methods#jwt-with-private-key) \n  - [Test JWT Profile for API Applications](https://github.com/zitadel/examples-api-access-and-token-introspection/tree/main/api-jwt)\n- [Basic Authentication](https://zitadel.com/docs/apis/openidoauth/authn-methods#client-secret-basic) \n  - [Test Basic Authentication for API Applications](https://github.com/zitadel/examples-api-access-and-token-introspection/tree/main/api-basic-authentication)\n\n\n\n## Service Users:\nIf there are client APIs or systems that need to access other protected APIs, these APIs or systems must be declared as service users. A service user is not considered an application type in ZITADEL. The following mechanisms are available for service users to obtain an access token: \n\n- [JSON Web Token (JWT) Profile  (Recommended)](https://zitadel.com/docs/guides/integrate/serviceusers) \n  - [Test JWT Profile for Service Users](https://github.com/zitadel/examples-api-access-and-token-introspection/tree/main/service-user-jwt)\n- [Client Credentials](https://zitadel.com/docs/guides/integrate/client-credential) \n  - [Test Client Credentials for Serivce Users](https://github.com/zitadel/examples-api-access-and-token-introspection/tree/main/service-user-client-credentials)\n- [Personal Access Tokens (PAT)](https://zitadel.com/docs/guides/integrate/pat) \n  - [Test Personal Access Tokens for Service Users](https://github.com/zitadel/examples-api-access-and-token-introspection/tree/main/service-user-pat)\n\n\n\n## All Possible Combinations: \n| **#** | **Grant and Token Type Used by Service User**                                         | **How the Application API Invokes the Introspection Endpoint** |\n|-------|---------------------------------------------------------------------------------------|----------------------------------------------------------------|\n| 1     | Send JWT to ZITADEL to receive an opaque token or JWT and send the received token to API (JWT Profile) | JWT Profile                                                    |\n| 2     | Send JWT to ZITADEL to receive an opaque token or JWT and send the received token to API (JWT Profile) | Basic Authentication                                           |\n| 3     | Send Client ID and Client Secret to ZITADEL and receive an opaque token or JWT and send the received token to API (Client Credentials) | JWT Profile                                                    |\n| 4     | Send Client ID and Client Secret to ZITADEL and receive an opaque token or JWT and send the received token to API (Client Credentials) | Basic Authentication                                           |\n| 5     | Send a static access token to API (Personal Access Token)                            | JWT Profile                                                    |\n| 6     | Send a static access token to API (Personal Access Token)                            | Basic Authentication                                           |\n\n\n## Prerequisites to Run the Samples: \n\n- Clone this repository. \n- Have python3 and pip3 installed in your machine.\n- Install required dependencies by running `pip3 install -r requirements.txt` on your terminal.\n- Create a free ZITADEL account here - https://zitadel.cloud/\n- Create an instance as explained [here](https://zitadel.com/docs/guides/start/quickstart#2-create-your-first-instance). \n- Create a new project in your instance by following the steps [here](https://zitadel.com/docs/guides/start/quickstart#2-create-your-first-instance).\n- Make sure that you replace the values in the .env file in each project with the values you obtain from ZITADEL.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzitadel%2Fexamples-api-access-and-token-introspection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzitadel%2Fexamples-api-access-and-token-introspection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzitadel%2Fexamples-api-access-and-token-introspection/lists"}