web: add custom readme to api client
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
38
scripts/web_api_readme.md
Normal file
38
scripts/web_api_readme.md
Normal file
@ -0,0 +1,38 @@
|
||||
## @goauthentik/api
|
||||
|
||||
This package provides a generated API Client for [authentik](https://goauthentik.io).
|
||||
|
||||
### 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: {
|
||||
"X-CSRFToken": 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