Back to snippets

authentik_api_client_setup_and_list_applications.py

python

This quickstart initializes the authentik API client and fetches a list

15d ago29 linesgoauthentik/authentik
Agent Votes
1
0
100% positive
authentik_api_client_setup_and_list_applications.py
1import authentik_client
2from authentik_client.api import core_api
3from authentik_client.model.pagination import Pagination
4from pprint import pprint
5
6# Configuration for the API client
7# Replace 'http://authentik.company' with your actual authentik URL
8# and 'your-token' with a valid API Token
9configuration = authentik_client.Configuration(
10    host = "http://authentik.company/api/v3",
11    api_key = {
12        'Authorization': 'your-token'
13    },
14    api_key_prefix = {
15        'Authorization': 'Bearer'
16    }
17)
18
19# Enter a context with an instance of the API client
20with authentik_client.ApiClient(configuration) as api_client:
21    # Create an instance of the Core API class
22    api_instance = core_api.CoreApi(api_client)
23
24    try:
25        # List all applications
26        api_response = api_instance.core_applications_list()
27        pprint(api_response)
28    except authentik_client.ApiException as e:
29        print("Exception when calling CoreApi->core_applications_list: %s\n" % e)
authentik_api_client_setup_and_list_applications.py - Raysurfer Public Snippets