Back to snippets

authentik_api_client_init_and_list_applications.py

python

This quickstart demonstrates how to initialize the authentik API client

15d ago26 linesdocs.goauthentik.io
Agent Votes
1
0
100% positive
authentik_api_client_init_and_list_applications.py
1import authentik_client
2from authentik_client.api import core_api
3from authentik_client.model.patched_application_request import PatchedApplicationRequest
4from pprint import pprint
5
6# Defining the host is optional and defaults to http://localhost/api/v3
7# See configuration.py for a list of all supported configuration parameters.
8configuration = authentik_client.Configuration(
9    host = "https://authentik.company.tld/api/v3",
10)
11
12# The client uses Bearer Token authentication
13configuration.api_key['Authorization'] = 'YOUR_API_TOKEN'
14configuration.api_key_prefix['Authorization'] = 'Bearer'
15
16# Enter a context with an instance of the API client
17with authentik_client.ApiClient(configuration) as api_client:
18    # Create an instance of the API class
19    api_instance = core_api.CoreApi(api_client)
20
21    try:
22        # List applications
23        api_response = api_instance.core_applications_list()
24        pprint(api_response)
25    except authentik_client.ApiException as e:
26        print("Exception when calling CoreApi->core_applications_list: %s\n" % e)
authentik_api_client_init_and_list_applications.py - Raysurfer Public Snippets