Skip to content

Instantly share code, notes, and snippets.

@saltukalakus
Created March 16, 2021 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saltukalakus/67656b539b460e8da4b94f48ed9aa407 to your computer and use it in GitHub Desktop.
Save saltukalakus/67656b539b460e8da4b94f48ed9aa407 to your computer and use it in GitHub Desktop.
Sample Auth0 action to execute on a specific API and Application for adding a custom claim.
/** @type {CredentialsExchangeAction} */
module.exports = async (event, context) => {
// This action works for an API with the API audience https://example.com/api along with an application with the
// client id 5drbxrf5qMc1KTFNEw6Wjrbw319pOiyW
if (event.audience === "https://example.com/api" && event.client.id === "5drbxrf5qMc1KTFNEw6Wjrbw319pOiyW") {
return {
customClaims: {
"https://www.customnamespace.com/some_key": "some value"
}
};
} else {
return {};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment