2021-08-23 11:00:35 +01:00
|
|
|
## @goauthentik/api
|
|
|
|
|
2021-10-20 15:31:10 +01:00
|
|
|
This package provides a generated API Client for [authentik](https://goauthentik.io?utm_source=npm-api-package).
|
2021-08-23 11:00:35 +01:00
|
|
|
|
|
|
|
### Building
|
|
|
|
|
|
|
|
See https://goauthentik.io/developer-docs/making-schema-changes
|
|
|
|
|
|
|
|
### 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: {
|
2022-01-16 15:17:44 +00:00
|
|
|
"X-authentik-CSRF": getCookie("authentik_csrf"),
|
2021-08-23 11:00:35 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
Then use the API:
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
import { CoreApi } from "@goauthentik/api";
|
|
|
|
|
|
|
|
const user = await new CoreApi(DEFAULT_CONFIG).coreUsersMeRetrieve();
|
|
|
|
```
|