Customize userinfo endpoint #94
Replies: 1 comment 2 replies
-
Hello @Headmaster11 Yes, it is possible to add custom claims to the userinfo response in Ory. Any information included in session.id_token when accepting the consent request will also be included in the response. Here is 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,
acceptOAuth2ConsentRequest: {
session: {
access_token: {
some_custom_claim: "some_custom_value",
},
id_token: {
id_custom_claim: "some_value",
},
},
},
})
.then(({ data }) => data)
} In this example, some_custom_claim and id_custom_claim are custom claims added to the userinfo response. The values of these claims are some_custom_value and some_value respectively. |
Beta Was this translation helpful? Give feedback.
-
Is is possible to set output data/schema for userinfo endpoint?
Currently I have only this data
On this is the only possible behaviour?
Beta Was this translation helpful? Give feedback.
All reactions