Skip to content

How to customize access token generated by client credentials flow #3616

Answered by vinckr
baominwang asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @baominwang

Yes, it is possible to add customized fields in the access token. This can be done by adding custom claims during the consent acceptance. Here's an example of how to do this:


import { Configuration, OAuth2Api } from "@ory/client"  
  
const ory = new OAuth2Api(  
 new Configuration({  
 basePath: `https://${process.env.ORY_PROJECT_SLUG}.projects.oryapis.com`,  
 accessToken: process.env.ORY_API_KEY,  
 }),  
)  
  
export async function acceptConsent(consentChallenge: string) {  
 const { data } = await ory.getOAuth2ConsentRequest({ consentChallenge })  
  
 return await ory  
 .acceptOAuth2ConsentRequest({  
 consentChallenge: consentChallenge,  
 acceptOAuth2ConsentRe…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vinckr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants