This API parses request parameters of an authorization request and returns necessary data for the authorization server implementation to process the authorization request further.
import { Authlete } from "@authlete/typescript-sdk";
const authlete = new Authlete({
bearer: process.env["AUTHLETE_BEARER"] ?? "",
});
async function run() {
const result = await authlete.token.process({
serviceId: "<id>",
tokenRequest: {
parameters: "grant_type=authorization_code&code=Xv_su944auuBgc5mfUnxXayiiQU9Z4-T_Yae_UfExmo&redirect_uri=https%3A%2F%2Fmy-client.example.com%2Fcb1&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
clientId: "26478243745571",
clientSecret: "gXz97ISgLs4HuXwOZWch8GEmgL4YMvUJwu3er_kDVVGcA0UOhA9avLPbEmoeZdagi9yC_-tEiT2BdRyH9dbrQQ",
},
});
console.log(result);
}
run();The standalone function version of this method:
import { AuthleteCore } from "@authlete/typescript-sdk/core.js";
import { tokenProcess } from "@authlete/typescript-sdk/funcs/tokenProcess.js";
// Use `AuthleteCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const authlete = new AuthleteCore({
bearer: process.env["AUTHLETE_BEARER"] ?? "",
});
async function run() {
const res = await tokenProcess(authlete, {
serviceId: "<id>",
tokenRequest: {
parameters: "grant_type=authorization_code&code=Xv_su944auuBgc5mfUnxXayiiQU9Z4-T_Yae_UfExmo&redirect_uri=https%3A%2F%2Fmy-client.example.com%2Fcb1&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
clientId: "26478243745571",
clientSecret: "gXz97ISgLs4HuXwOZWch8GEmgL4YMvUJwu3er_kDVVGcA0UOhA9avLPbEmoeZdagi9yC_-tEiT2BdRyH9dbrQQ",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("tokenProcess failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AuthTokenApiRequest | ✔️ | The request object 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<models.TokenResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ResultError | 400, 401, 403 | application/json |
| errors.ResultError | 500 | application/json |
| errors.AuthleteDefaultError | 4XX, 5XX | */* |
This API generates a content of an error token response that the authorization server implementation returns to the client application.
import { Authlete } from "@authlete/typescript-sdk";
const authlete = new Authlete({
bearer: process.env["AUTHLETE_BEARER"] ?? "",
});
async function run() {
const result = await authlete.token.fail({
serviceId: "<id>",
tokenFailRequest: {
ticket: "83BNqKIhGMyrkvop_7jQjv2Z1612LNdGSQKkvkrf47c",
reason: "INVALID_RESOURCE_OWNER_CREDENTIALS",
},
});
console.log(result);
}
run();The standalone function version of this method:
import { AuthleteCore } from "@authlete/typescript-sdk/core.js";
import { tokenFail } from "@authlete/typescript-sdk/funcs/tokenFail.js";
// Use `AuthleteCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const authlete = new AuthleteCore({
bearer: process.env["AUTHLETE_BEARER"] ?? "",
});
async function run() {
const res = await tokenFail(authlete, {
serviceId: "<id>",
tokenFailRequest: {
ticket: "83BNqKIhGMyrkvop_7jQjv2Z1612LNdGSQKkvkrf47c",
reason: "INVALID_RESOURCE_OWNER_CREDENTIALS",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("tokenFail failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AuthTokenFailApiRequest | ✔️ | The request object 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<models.TokenFailResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ResultError | 400, 401, 403 | application/json |
| errors.ResultError | 500 | application/json |
| errors.AuthleteDefaultError | 4XX, 5XX | */* |
This API generates a content of a successful token response that the authorization server implementation returns to the client application.
import { Authlete } from "@authlete/typescript-sdk";
const authlete = new Authlete({
bearer: process.env["AUTHLETE_BEARER"] ?? "",
});
async function run() {
const result = await authlete.token.issue({
serviceId: "<id>",
tokenIssueRequest: {
ticket: "p7SXQ9JFjng7KFOZdCMBKcoR3ift7B54l1LGIgQXqEM",
subject: "john",
},
});
console.log(result);
}
run();The standalone function version of this method:
import { AuthleteCore } from "@authlete/typescript-sdk/core.js";
import { tokenIssue } from "@authlete/typescript-sdk/funcs/tokenIssue.js";
// Use `AuthleteCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const authlete = new AuthleteCore({
bearer: process.env["AUTHLETE_BEARER"] ?? "",
});
async function run() {
const res = await tokenIssue(authlete, {
serviceId: "<id>",
tokenIssueRequest: {
ticket: "p7SXQ9JFjng7KFOZdCMBKcoR3ift7B54l1LGIgQXqEM",
subject: "john",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("tokenIssue failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AuthTokenIssueApiRequest | ✔️ | The request object 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<models.TokenIssueResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ResultError | 400, 401, 403 | application/json |
| errors.ResultError | 500 | application/json |
| errors.AuthleteDefaultError | 4XX, 5XX | */* |