Authenticating with User Name and Password

This use case provides a step-by-step example of using the Oracle Identity Cloud Service Authenticate API to authenticate with a user's credentials.

Note:

Use this Authenticate API only if you're building your own end-to-end login experience by developing a custom sign-in application to be used by Oracle Identity Cloud Servcice.

Note:

This Authenticate API can't be used to integrate your applications with Oracle Identity Cloud Service for single sign-on purposes.

Note:

See the Oracle Identity Cloud Service Authentication API Postman collection for extensive authentication use case examples. Download the collection and the global variables file from the idcs-authn-api-rest-clients folder within GitHub and then import them into Postman.
There are two steps in this use case. Each step contains request and response examples::

Step 1: Begin the Authentication Flow

Obtain the initial requestState to begin the authentication flow.

Step 1 Request Example

The following example shows the request in cURL format:

curl
-X GET
-H "Content-Type: application/json"
-H "Authorization: Bearer {{access_token_value}}"
https://tenant-base-url/sso/v1/sdk/authenticate?appName={{app_name}}

Note:

 The appName is optional. The appName is the name of the App that the client wants to access. If an appName is provided, sign-on policies specific to the App are processed, and the client is challenged for the required factors based on that policy.

Step 1 Response Example

The following example shows the contents of the response in JSON format:

{
    "requestState": "ZThJpG52InI1.....mNB3tRgFpl",
    "nextOp": [
        "credSubmit"
    ],
    "USERNAME_PASSWORD": {
        "credentials": [
            "username",
            "password"
        ]
    },
    "nextAuthFactors": [
        "USERNAME_PASSWORD"
    ],
    "status": "success"
}

In the response, the nextOp value indicates what can be sent as the op value in the next request. In this use case example, credSubmit should be sent in the next step. The requestState contains contextual data needed to process the request.

Step 2: Submit the User's Credentials

Submit the user's credentials as the first factor, which are the user name and password. For this step, the client must include the following attributes:
  • credentials: user name and password

  • requestState: received in the Step 1 response

  • op: tells the server what kind of operation the client wants

Step 2 Request Example

The following example shows the contents of the POST request in JSON format to the /sso/v1/sdk/authenticate endpoint:

{  
   "op":"credSubmit",
   "credentials":{  
      "username":"{{username}}",
      "password":"{{password}}"
   },

   "requestState":"{{requestState}}"

}

Step 2 Response Example

The following example shows the contents of the response in JSON format:

{
    "authnToken": "eyJraWQiOiJT.....UKofudtemmJE",
    "status": "success"
}

Step 2 Error Response Example

The following example shows the contents of the response in JSON format when the user name or password provided is invalid:

{
    "status": "failed",
    "cause": [
        {
            "message": "You entered an incorrect user name or password.",
            "code": "AUTH-3001"
        }
    ],
    "requestState": "e5kwGYx57taQ.....jyg3nEDFya"
}