<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D50Z00008G7VJ1SANOkta Classic EngineLifecycle ManagementAnswered2023-02-20T22:39:00.000Z2017-08-22T12:05:28.000Z2017-08-22T12:05:28.000Z
Immediate access to login after user creation
Hello, I am attempting to add a new User which should be able to immediately use the credentials to log himself in. I am using the following section in the documentation to do so: https://developer.okta.com/docs/api/resources/users.html#create-user-with-password

 

The user is added successfully. When attempting to login the new user (using the  {{url}}/api/v1/authn API), I keep getting "Authentication failed". The Okta log shows "VERIFICATION_ERROR". I want the user to be authenticated even if a verification has not yet been done. Any help is greatly apreciated.

  • Hi Morten,

     

    Please try this call:

    curl -v -X POST \

    -H "Accept: application/json" \

    -H "Content-Type: application/json" \

    -H "Authorization: SSWS ${api_token}" \

    -d '{

      "profile": {

        "firstName": "Isaac",

        "lastName": "Brock",

        "email": "isaac.brock@example.com",

        "login": "isaac.brock@example.com",

        "mobilePhone": "555-415-1337"

      },

      "credentials": {

        "password" : { "value": "tlpWENT2m" }

      }

    }' "https://{yourOktaDomain}.com/api/v1/users?activate=true"

     

    After the call is done please do test it out. It should give no further errors for the Verification.
    Expand Post
  • MortenL.74635 (Customer)

    Hi Adrian, this did indeed help - thanks! I got this to work with the pure RESTful call. I had to update the Okta-provided Java SDK to use the newest snapshot versions to get access to the 'setActive(...)' method :

     

    [...]

        // Security API

        compile 'com.okta.sdk:okta-sdk-api:0.6.1-SNAPSHOT'

        compile 'com.okta.sdk:okta-sdk-impl:0.6.1-SNAPSHOT'

        compile 'com.okta.sdk:okta-sdk-httpclient:0.6.1-SNAPSHOT'

     

    [...]

    User user = UserBuilder.instance()

       .setEmail(jsonRequestBody.getString("email"))

       .setFirstName(jsonRequestBody.getString("given_name"))

       .setLastName(jsonRequestBody.getString("surname"))

       .setPassword(jsonRequestBody.getString("password"))

       .setActive(true)

       .buildAndCreate(client);
    Expand Post
This question is closed.
Loading
Immediate access to login after user creation