Operations related to Application Access Tokens
- create - Create an application access token
Generate an application access token using OAuth 2.0 client credentials flow for server-to-server authentication. Requires client ID and secret sent via Basic authentication header with grant_type=client_credentials in the request body. Returns a bearer access token with expiration time for authenticating API requests scoped to your application. Essential for secure API access.
import { Dwolla } from "dwolla";
const dwolla = new Dwolla();
async function run() {
const result = await dwolla.tokens.create({
basicAuth: process.env["DWOLLA_BASIC_AUTH"] ?? "",
}, {
grantType: "client_credentials",
});
console.log(result);
}
run();The standalone function version of this method:
import { DwollaCore } from "dwolla/core.js";
import { tokensCreate } from "dwolla/funcs/tokensCreate.js";
// Use `DwollaCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dwolla = new DwollaCore();
async function run() {
const res = await tokensCreate(dwolla, {
basicAuth: process.env["DWOLLA_BASIC_AUTH"] ?? "",
}, {
grantType: "client_credentials",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("tokensCreate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CreateApplicationAccessTokenRequest | ✔️ | The request object to use for the request. |
security |
operations.CreateApplicationAccessTokenSecurity | ✔️ | The security requirements to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.CreateApplicationAccessTokenResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedError | 401 | application/json |
| errors.APIError | 4XX, 5XX | */* |