Grant type for create user

Hey ,
I have been trying to use auth0 api v2 to create users . Here is my sample request
curl -X POST -H "Authorization: Bearer " -H "Content-Type: application/json" -d '{"email":"john.doe@gmail.com","phone_number":"+199999999999999","user_metadata":{},"blocked":false,"email_verified":false,"phone_verified":false,"app_metadata":{},"given_name":"John","family_name":"Doe","name":"John Doe","nickname":"Johnny","picture":"https://secure.gravatar.com/avatar/15626c5e0c749cb912f9d1ad48dba440?s=480&r=pg&d=https%3A%2F%2Fssl.gstatic.com%2Fs2%2Fprofiles%2Fimages%2Fsilhouette80.png","user_id":"","connection":"Initial-Connection","password":"secret","verify_email":false,"username":"johndoe"}' "https://shipt1.auth0.com/api/v2/users"

but I am continuously getting error Insufficient scope, expected any of: create:users . I generated bearer token using client_credentials grant type but it seems like it is not working

Hi @obi ,
It appears you are FE …

Did you call-1 return the access_token along with sufficient scope ( create user) .

In order to add/create a new user you need to make to calls :

  1. https://shipt1.auth0.com/oauth/token (POST)
    Request Data :
    {
    “client_id”:“YOUR_CLEINT_ID”,
    “client_secret”:“YOUR_CLIENT_SECRET____”,
    “audience”:“https://shipt1.auth0.com/api/v2/”,
    “grant_type”:“client_credentials”
    }

Response :
{
“access_token”: “data”,
“scope”: "read:client_grants create:client_grants delete:client_grants update:client_grants read:users update:users delete:users create:users read:users_app_metadata update:users_app_metadata delete:users_app_metadata create:users_app_metadata ",
“expires_in”: 86400,
“token_type”: “Bearer”
}
2.
NOW use the " access_token " (in header) to call : https://shipt1.auth0.com/api/v2/users (POST)
Request Data :
{
“connection”: “Username-Password-Authentication”,
“email”: “john.doe@gmail.com”,
“password”: “SOME_PWD”,
“user_metadata”: {
“name” : “John Doe”
},
“email_verified”: false,
“verify_email”: false,
“app_metadata”: {}
}

In Response , you will get the user-obj back .

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