Functions
generateAccessToken()
generateAccessToken(
params?):Promise<string>
Defined in: cognito/generate-access-token.ts:38
Generates an OAuth 2.0 access token using the client credentials flow.
Useful in E2E and integration tests when you need to authenticate against protected APIs before making test requests.
Parameters
params?
AccessTokenParams = {}
The authentication parameters
Returns
Promise<string>
The access token string
Throws
Error if the token request fails or required environment variables are missing
Example
// Minimal — uses environment variables
const token = await generateAccessToken();
// Explicit overrides
const token = await generateAccessToken({
cognitoDomain: 'my-app',
region: 'us-east-1',
clientId: 'my-client-id',
clientSecret: 'my-client-secret',
scopes: ['read:users', 'write:orders'],
});