Facebook login does not call login flow

When I signup via Facebook, the login flow is called and my token is enriched with the relevant data. However, after 2-4 days, the token suddenly no longer has the custom claims. The only thing that helps then is to delete the account so that the user has to register again.

exports.onExecutePostLogin = async (event, api) => {
    api.accessToken.setCustomClaim('xxx_email', event.user.user_metadata.email);
    api.accessToken.setCustomClaim('xxx_given_name', event.user.user_metadata.given_name);
    api.accessToken.setCustomClaim('xxx_family_name', event.user.user_metadata.family_name);
};

makes no difference in using onContinueLogin or onExecutePostLogin.
can anyone confirm or show me, how can I reliable add custom claims to the token?

Hi @p.friedrich,

I am unsure what might be causing the token to lose custom claims after 2-4 days. I recommend reviewing your tenant logs and the user’s profile to ensure that the data is still in user_metadata and that successful logins are reflected. Also, check the action tab in the successful login logs to verify if the action scripts executed properly.

Additionally, your post-login action script might need to use namespaced custom claims for them to be properly added. This could be the issue with the custom claims not persisting.

Please refer to our Adding custom claims to tokens knowledge solution.

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.