Universal login doesn't work with post-login action in React

Hi,

we have a React (Typescript) application with Universal Login. The user login works perfectly. But we would like to assign roles to user on first login.

We followed this video: https://www.youtube.com/watch?v=B5pzpPqPbbM

We tried login from Dashboard (like the lady in the video) and it worked. But when we try to login in our React app with the universal login it does not work.

We get back an unauthorized error.

To make Post-Login action to work we had to set “Authentication Method” from “None” to “Client Secret (Post)” and in the Settings → Advanced Settings → Grant Types we checked “Client Credentials” option.

If we switch from “Client Secret (Post)” to “None” then the login works but the action does not (we got the following error: AuthApiError: Grant type ‘client_credentials’ not allowed for the client.\n at OAuth.parseError (/data/layers/layers-GH-v/GH-vlzQIts7oMVQoMATHHepPqgU7LvJnMmf-9-IHPrA/node_modules/auth0/dist/cjs/auth/base-auth-api.js:43:16)\n at process.processTicksAndR").

So we basically would like to solve that when a user logs-in first time he/she gets his/her roles automatically.

Can you tell the steps we have to make both (login and action) work?

Thank you for help!

Hi @pemikdev,

Welcome to the Auth0 Community!

You should not allow the client credentials grant in a single page application. Further, the settings you describe (Authentication Method) are intended for private clients, not in single page apps.

Please create a new application for your React app in the dashboard and select the following:

Regardless of this, these setting shouldn’t impact whether or not your post login action runs, as long as a user logs in.

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