- processRequest - Process Grant Management Request
The API is for the implementation of the grant management endpoint which is defined in "Grant Management for OAuth 2.0".
import { Authlete } from "@authlete/typescript-sdk";
const authlete = new Authlete({
bearer: process.env["AUTHLETE_BEARER"] ?? "",
});
async function run() {
const result = await authlete.grantManagement.processRequest({
serviceId: "<id>",
gMRequest: {
accessToken: "eyJhbGciOiJFUzI1NiJ9.eyJleHAiOjE1NTk4MTE3NTAsImlzcyI6IjU3Mjk3NDA4ODY3In0K.csmdholMVcmjqHe59YWgLGNvm7I5Whp4phQCoGxyrlRGMnTgsfxtwyxBgMXQqEPD5q5k9FaEWNk37K8uAtSwrA",
gmAction: "REVOKE",
grantId: "57297408867",
},
});
console.log(result);
}
run();The standalone function version of this method:
import { AuthleteCore } from "@authlete/typescript-sdk/core.js";
import { grantManagementProcessRequest } from "@authlete/typescript-sdk/funcs/grantManagementProcessRequest.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 grantManagementProcessRequest(authlete, {
serviceId: "<id>",
gMRequest: {
accessToken: "eyJhbGciOiJFUzI1NiJ9.eyJleHAiOjE1NTk4MTE3NTAsImlzcyI6IjU3Mjk3NDA4ODY3In0K.csmdholMVcmjqHe59YWgLGNvm7I5Whp4phQCoGxyrlRGMnTgsfxtwyxBgMXQqEPD5q5k9FaEWNk37K8uAtSwrA",
gmAction: "REVOKE",
grantId: "57297408867",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("grantManagementProcessRequest failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GrantMApiRequest | ✔️ | 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.GMResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ResultError | 400, 401, 403 | application/json |
| errors.ResultError | 500 | application/json |
| errors.AuthleteDefaultError | 4XX, 5XX | */* |