|
10 | 10 | from zitadel_client.api.user_service_api import UserServiceApi |
11 | 11 | from zitadel_client.api_client import ApiClient |
12 | 12 | from zitadel_client.auth.authenticator import Authenticator |
| 13 | +from zitadel_client.auth.client_credentials_authenticator import ClientCredentialsAuthenticator |
| 14 | +from zitadel_client.auth.personal_access_token_authenticator import PersonalAccessTokenAuthenticator |
| 15 | +from zitadel_client.auth.web_token_authenticator import WebTokenAuthenticator |
13 | 16 | from zitadel_client.configuration import Configuration |
14 | 17 |
|
15 | 18 |
|
@@ -93,3 +96,40 @@ def __exit__( |
93 | 96 | traceback: The traceback of the exception, if an exception occurred. |
94 | 97 | """ |
95 | 98 | pass |
| 99 | + |
| 100 | + @staticmethod |
| 101 | + def with_access_token(host: str, access_token: str) -> "Zitadel": |
| 102 | + """ |
| 103 | + Initialize the SDK with a Personal Access Token (PAT). |
| 104 | +
|
| 105 | + :param host: API URL (e.g., "https://api.zitadel.example.com"). |
| 106 | + :param access_token: Personal Access Token for Bearer authentication. |
| 107 | + :return: Configured Zitadel client instance. |
| 108 | + :see: https://zitadel.com/docs/guides/integrate/service-users/personal-access-token |
| 109 | + """ |
| 110 | + return Zitadel(PersonalAccessTokenAuthenticator(host, access_token)) |
| 111 | + |
| 112 | + @staticmethod |
| 113 | + def with_client_credentials(host: str, client_id: str, client_secret: str) -> "Zitadel": |
| 114 | + """ |
| 115 | + Initialize the SDK using OAuth2 Client Credentials flow. |
| 116 | +
|
| 117 | + :param host: API URL. |
| 118 | + :param client_id: OAuth2 client identifier. |
| 119 | + :param client_secret: OAuth2 client secret. |
| 120 | + :return: Configured Zitadel client instance with token auto-refresh. |
| 121 | + :see: https://zitadel.com/docs/guides/integrate/service-users/client-credentials |
| 122 | + """ |
| 123 | + return Zitadel(ClientCredentialsAuthenticator.builder(host, client_id, client_secret).build()) |
| 124 | + |
| 125 | + @staticmethod |
| 126 | + def with_private_key(host: str, key_file: str) -> "Zitadel": |
| 127 | + """ |
| 128 | + Initialize the SDK via Private Key JWT assertion. |
| 129 | +
|
| 130 | + :param host: API URL. |
| 131 | + :param key_file: Path to service account JSON or PEM key file. |
| 132 | + :return: Configured Zitadel client instance using JWT assertion. |
| 133 | + :see: https://zitadel.com/docs/guides/integrate/service-users/private-key-jwt |
| 134 | + """ |
| 135 | + return Zitadel(WebTokenAuthenticator.from_json(host, key_file)) |
0 commit comments