I’m currently having some issues regarding the authorization extension. I always get a “Invalid token” response.
What I want to do is set the role after user creation via api.
I’ll omit the code from the user creation, since it’s working.
//auth0ClientId → My main app client id, the one I’m using for user signup
//auth0ClientSecret → Secret from the app I’m using for user signup
//auth0AuthorizationAudience-> The audience from authorization-extension in the APIs page, which is urn:auth0-authz-api
//auth0Endpoint → My tenant, the one I get from the domain of my app
const resultAuthorizationToken = await axios.post(${context.app.get('auth0Endpoint')}/oauth/token, data);
//auth0AuthorizationEndpoint → The URL I get in the API section in the Authorization Extension page
//user.user_id → the id of the user I’ve created. I get it in this format: auth0|HASH
const resultAuthorization = await axios.patch(${this.app.get('auth0AuthorizationEndpoint')}/users/${user.user_id}/roles, [‘seller’], {
headers: {
Authorization: Bearer ${resultAuthorizationToken.data.access_token};
});
Geez, after I posted this, I realized a typo. Instead of authorizationTokenData in the post for the token, I sent “data”. Sometimes you just need to see it from another point of view haha.