alepha@docs:~/docs/reference/primitives$
cat $serviceAccount.md1 min read
#$serviceAccount
#Import
typescript
1import { $serviceAccount } from "alepha/security";
#Overview
Allow to get an access token for a service account.
You have some options to configure the service account:
- a OAUTH2 URL using client credentials grant type
- a JWT secret shared between the services
#Options
| Option | Type | Required | Description |
|---|---|---|---|
gracePeriod |
number; // Grace period in milliseconds before token expi... |
No |
#Examples
ts
1import { $serviceAccount } from "alepha/security"; 2 3class MyService { 4 serviceAccount = $serviceAccount({ 5 oauth2: { 6 url: "https://example.com/oauth2/token", 7 clientId: "your-client-id", 8 clientSecret: "your-client-secret", 9 }10 });11 12 async fetchData() {13 const token = await this.serviceAccount.token();14 // or15 const response = await this.serviceAccount.fetch("https://api.example.com/data");16 }17}