authentik/scripts/api-ts-templates
Simonyi Gergő 6da0548fa2
scripts: fix broken link (#13156)
fix broken link
2025-02-21 12:51:51 +01:00
..
README.mustache scripts: fix broken link (#13156) 2025-02-21 12:51:51 +01:00

README.mustache

## @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();
```