hundreds-match-36539
05/22/2024, 10:21 AMchilly-king-10285
05/22/2024, 10:21 AMchilly-king-10285
05/22/2024, 10:21 AMsetOAuth2ClientLifespans
method in the Ory SDK. Here is an example of how to do this: javascript import { Configuration, OAuth2Api } from "@ory/client" const ory = new OAuth2Api( new Configuration({ basePath: `https://${process.env.ORY_PROJECT_SLUG}.<http://projects.oryapis.com|projects.oryapis.com>`, accessToken: process.env.ORY_API_KEY, }), ) export async function setClientLifespans(clientId: string) { await ory.setOAuth2ClientLifespans({ id: clientId, oAuth2ClientTokenLifespans: { authorization_code_grant_access_token_lifespan: "168h", authorization_code_grant_id_token_lifespan: "168h", authorization_code_grant_refresh_token_lifespan: "168h", client_credentials_grant_access_token_lifespan: "168h", implicit_grant_access_token_lifespan: "168h", implicit_grant_id_token_lifespan: "168h", jwt_bearer_grant_access_token_lifespan: "168h", refresh_token_grant_access_token_lifespan: "168h", refresh_token_grant_id_token_lifespan: "168h", refresh_token_grant_refresh_token_lifespan: "168h", }, }) }
In this example, the lifespan of the tokens is set to "168h", which is equivalent to 7 days. Replace clientId
with the ID of the client you want to modify. Please note that you need to be authenticated to perform this operation. The authentication method is oryAccessToken
. For more information, refer to the [Ory API Reference](https://www.ory.sh/docs/reference/api) and the [Ory Hydra Guide on configuring token expiration time](https://www.ory.sh/docs/hydra/guides/client-token-expiration#lifespan-configuration-for-specific-clients).hundreds-match-36539
05/23/2024, 10:33 AMchilly-king-10285
05/23/2024, 10:33 AMchilly-king-10285
05/23/2024, 10:33 AMjavascript refresh_token_grant_refresh_token_lifespan: "168h", // 7 days
In this example, the lifespan of the refresh token is set to "168h", which is equivalent to 7 days. For more information, refer to the [Ory API Reference](https://www.ory.sh/docs/hydra/reference/api) and the [Ory Hydra Guide on configuring token expiration time](https://www.ory.sh/docs/hydra/guides/client-token-expiration#lifespan-configuration-for-specific-clients).