mirror of
https://github.com/goauthentik/authentik
synced 2026-04-26 01:25:02 +02:00
root: move API client generation to docker-compose (#17434)
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
committed by
GitHub
parent
296b348bd2
commit
d91dcf4eef
38
scripts/api/ts-templates/README.mustache
Normal file
38
scripts/api/ts-templates/README.mustache
Normal file
@@ -0,0 +1,38 @@
|
||||
## @goauthentik/api
|
||||
|
||||
This package provides a generated API Client for [authentik](https://goauthentik.io?utm_source=npm-api-package).
|
||||
|
||||
### Building
|
||||
|
||||
See https://docs.goauthentik.io/docs/developer-docs/api/making-schema-changes#building-the-web-client
|
||||
|
||||
### Consuming
|
||||
|
||||
```
|
||||
npm install @goauthentik/api --save
|
||||
```
|
||||
|
||||
Create a configuration:
|
||||
|
||||
```typescript
|
||||
import { Configuration } from "@goauthentik/api";
|
||||
|
||||
export const DEFAULT_CONFIG = new Configuration({
|
||||
// Configure where the API is located
|
||||
// Can be a full host, ensure CORS is configured
|
||||
basePath: "",
|
||||
// Required for POST/PUT/DELETE requests
|
||||
// getCookie function must return the cookie's contents
|
||||
headers: {
|
||||
"X-authentik-CSRF": getCookie("authentik_csrf"),
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Then use the API:
|
||||
|
||||
```typescript
|
||||
import { CoreApi } from "@goauthentik/api";
|
||||
|
||||
const user = await new CoreApi(DEFAULT_CONFIG).coreUsersMeRetrieve();
|
||||
```
|
||||
Reference in New Issue
Block a user