Skip to content

Commit

Permalink
Add more corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
bcbogdan committed Sep 30, 2024
1 parent febfb13 commit 36b67a3
Show file tree
Hide file tree
Showing 16 changed files with 801 additions and 359 deletions.
166 changes: 0 additions & 166 deletions v2/oauth/create-an-authentication-provider.mdx

This file was deleted.

110 changes: 108 additions & 2 deletions v2/oauth/customizations/add-custom-claims-in-tokens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,113 @@ title: Add Custom Claims in Tokens
hide_title: true
---

# Add custom claims in the ID / access token
import BackendSDKTabs from "/src/components/tabs/BackendSDKTabs"
import TabItem from '@theme/TabItem';

If you want to properties in the token payloads you can do this by overriding either the `buildIdTokenPayload` or the `buildAccessTokenPayload` functions.
# Add custom claims in the tokens

If you want to add custom properties in the token payloads you can do this by using overrides


## Override the OAuth2 Access Token


<BackendSDKTabs>

<TabItem value="nodejs">

```typescript
OAuth2Provider.init({
override: {
functions: (originalImplementation) => ({
...originalImplementation,
buildAccessTokenPayload: async (input) => {
const addedInfo: Record<string, any> = {};
if (input.scopes.includes("profile")) {
addedInfo.profile = "custom-value";
}
return {
...(await originalImplementation.buildAccessTokenPayload(input)),
profile: "custom-value",
};
},
}),
},
});

```

</TabItem>

<TabItem value="go">

:::caution

At the moment we do not have support creating OAuth2 providers in the Go SDK.

:::

</TabItem>

<TabItem value="python">

:::caution

At the moment we do not have support creating OAuth2 providers in the Python SDK.

:::

</TabItem>

</BackendSDKTabs>

## Override the ID Token

<BackendSDKTabs>

<TabItem value="nodejs">

```typescript
OAuth2Provider.init({
override: {
functions: (originalImplementation) => ({
...originalImplementation,
buildIdTokenPayload: async (input) => {
const addedInfo: Record<string, any> = {};
if (input.scopes.includes("profile")) {
addedInfo.profile = "custom-value";
}
return {
...(await originalImplementation.buildIdTokenPayload(input)),
profile: "custom-value",
};
},
}),
},
});

```

</TabItem>

<TabItem value="go">

:::caution

At the moment we do not have support creating OAuth2 providers in the Go SDK.

:::

</TabItem>

<TabItem value="python">

:::caution

At the moment we do not have support creating OAuth2 providers in the Python SDK.

:::

</TabItem>

</BackendSDKTabs>
Loading

0 comments on commit 36b67a3

Please sign in to comment.