Hi @g.felippe5965,
I understand you are trying to migrate your existing Rules to Actions.
This check is unnecessary because a namespaced claim can only be appended to the tokens after the authentication flow has completed.
Therefore, to simplify your code and use Actions, I have attached the converted code snippet below:
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://myapp.example.com';
if (event.authorization) {
// Set claims in ID token
api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
// Set claims in access token
api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
}
};
(Reference: Adding custom claims to tokens)
Cheers,
Rueben