In Post-login trigger I created an action that collects family_name and given_name from a form.
exports.onExecutePostLogin = async (event, api) => {
const form_id = 'form_id';
if(event.user.given_name==null || event.user.family_name==null)
{
api.prompt.render(form_id);
}else{
return;
}
};
exports.onContinuePostLogin = async (event, api) => {
const givenName = event.prompt.fields.given_name;
const familyName = event.prompt.fields.family_name;
const ManagementClient = require('auth0').ManagementClient;
const management = new ManagementClient({
domain: event.secrets.domain,
clientId: event.secrets.clientId,
clientSecret: event.secrets.clientSecret
});
const params = { id: event.user.user_id};
const data = {
"family_name" : familyName,
"given_name" : givenName
}
try{
const res = await management.users.update(params, data);
console.log("response ", res);
}catch(e){
console.log('logged error is', e);
}
return;
};
I have added the Dependencies auth0@4.18.0 to the action and secrets as well.
When I try to update/create user profile with family_name and given_name Iâm getting the error below.
logged error is AuthApiError: Grant type âclient_credentialsâ not allowed for the client.
at OAuth.parseError (/data/layers/core.windows.net/K5K9mAdro_Ps3rfuIeWZNilCuA4S63U8XEGvr8a7YI0=/node_modules/auth0/dist/cjs/auth/base-auth-api.js:43:16)
.
.
.
at async UsersManager.update (/data/layers/core.windows.net/K5K9mAdro_Ps3rfuIeWZNilCuA4S63U8XEGvr8a7YI0=/node_modules/auth0/dist/cjs/management/__generated/managers/users-manager.js:561:26)
at async exports.onContinuePostLogin (/data/io/node22/ec817423-b816-47eb-9855-058bd48631e9/webtask.js:40:20) {
error: âunauthorized_clientâ,
error_description: âGrant type âclient_credentialsâ not allowed for the client.â,
statusCode: 403,
body: {"error":"unauthorized_client","error_description":"Grant type 'client_credentials' not allowed for the client.","error_uri":"https://manage.teranet.auth0app.com/docs/clients/client-grant-types"}
,
.
.
I tried to enable Client Credentials in Applications â Your Application â Advanced Settings â Grant Types, but this type is in disabled status since it is not M2M.
Please let me know how to update (or create if family/given name does not exist) user profile.