Skip to content

Commit 9bfc54e

Browse files
authored
specify oauth docs (#1215)
1 parent 230ae5f commit 9bfc54e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

fern/products/docs/pages/authentication/set-up-oauth.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ Fern will need the following details to configure OAuth authentication:
2525
- [ ] Scopes (e.g. `openid`, `profile`, `email`)
2626
- [ ] Issuer URL (e.g. `https://<your-domain>`)
2727

28+
<Note title="Specifying an audience">
29+
If your client is connected to an API, you may need to specify an audience in the authentication request.
30+
31+
The updated authorization URL may look like this: `https://<your-oauth-tenant>/oauth2/authorize?audience=<your-api-identifier>`
32+
</Note>
33+
2834
Send these details to [email protected] or in your dedicated Slack channel.
2935
</Step>
3036

@@ -54,6 +60,10 @@ Add a custom claim to your OAuth provider's token response. This claim will be u
5460
}
5561
```
5662

63+
<Warning title="Using a claim other than `roles`">
64+
Some OAuth providers have strict requirements for custom claims. If you need to use a claim other than `roles`, please reach out to Fern and specify which claim should be parsed for the user's roles.
65+
</Warning>
66+
5767
<AccordionGroup>
5868
<Accordion title="Using Auth0">
5969
To add a custom claim to Auth0, you need to create a **custom action**. This action will be used to add the custom claim to the token response.
@@ -62,6 +72,16 @@ To add a custom claim to Auth0, you need to create a **custom action**. This act
6272
2. Create a **Custom Action**.
6373
3. Select **Login/Post Login**.
6474
4. Add logic to set a roles.
75+
```js Example Action
76+
exports.onExecutePostLogin = async (event, api) => {
77+
const roles = event.user.app_metadata?.roles; // or however you store user roles
78+
79+
if (roles) {
80+
const namespace: "https://<your-domain>.com"; // important: custom claims must be namespaced
81+
api.accessToken.setCustomClaim(`${namespace}/roles`, roles);
82+
}
83+
};
84+
```
6585
5. Click **Create**.
6686
6. Add the action to your **Post Login Flow**.
6787
</Accordion>

0 commit comments

Comments
 (0)