Obtaining an Access Token by Using the User Credentials Without a Client Assertion

Using the resource owner password credentials workflow, the OAuth client can obtain an access token by providing the user’s credentials (that is the user name and password).

This workflow has a resource owner request that uses the user identifier and password of the resource owner.

Obtaining an Access Token by Using the User Credentials

The resource owner password credentials grant workflow, allows you to obtain an access token by using the user’s credentials.

Parameters used in the access token request:
  • X-USER-IDENTITY-DOMAIN-NAME: The name of the identity domain.
  • Authorization: Basic: The basic authorization header. The client identifier and client secret of the client application is base64–encoded and sent in the header. For example, the Authorization header has the value of base64encoded(client_id:client_secret).
  • Content-Type: The type of content that’s sent in the request. It’s a URL-encoded application.
  • Request: The type of request that’s sent. Here, it’s a POST request to obtain an access token. This is followed by the authorization server URL which provides tokens.
  • grant_type: The grant type used to obtain the token. In the example that follows, it’s resource owner password credentials grant. The value of password is given for this grant type.
  • username: The name of the user.
  • password: The name of the password.
  • scope: The limit of a particular scope for an access token.

The client identifier and client secret of the client application is base64–encoded and sent in the header. This is sent along with the user’s credentials to obtain an access token.

To obtain an access token that contains the user and client credentials, use the following cURL command:

curl -i -H 'X-USER-IDENTITY-DOMAIN-NAME: OAuthTestTenant125' 
-H 'Authorization: Basic MzAzYTI0OTItZDY0Zi00ZTA0LWI3OGYtYjQzMzAwNDczMTJiOll5Sk5NSkdFc0ZqUkxWZVZsdVMz' 
-H 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8'
--request POST https://<idm-domain>.identity.<data-center>.oraclecloud.com/oauth/tokens 
-d 'grant_type=password
&username=tenantAdminUser
&password=Fusionapps1
&scope=http://www.example.com'

The output of the cURL command is:
{
"expires_in":3600,
"token_type":"Bearer",
"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsIng1dCI6Ild3cmVwdTJkYXNhSXBHUi1BbFZwSGtVQjZKZyIsIm
tpZCI6Ik9BdXRoVGVzdFRlbmFudDEyNS5jZXJ0In0.eyJzdWIiOiJ0ZW5hbnRBZG1pblVzZXIiLCJvcmFjbGUub2F1dGgudXNlcl9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otZjofbXca6dZpCxEWhfL06VHFiW-33GQpenpYCA-x8XWmQtUR6c_jkE6TlMPp7AzR32Qud
nAA"}

The JavaScript Object Notation web token (JWT) obtained can be decoded and the claims in the access token can be viewed as follows:

Access Token:
{
 alg: "RS256",
 typ: "JWT",
 x5t: "Wwrepu2dasaIpGR-AlVpHkUB6Jg",
 kid: "OAuthTestTenant125.cert"
}.
{
 sub: "tenantAdminUser",
 oracle.oauth.user_origin_id_type: "LDAP_UID",
 oracle.oauth.user_origin_id: "tenantAdminUser",
 iss: "OAuthTestTenant125",
 oracle.oauth.svc_p_n: "OAuthTestTenant125ServiceProfile",
 iat: 1425423619000,
 oracle.oauth.prn.id_type: "LDAP_UID",
 oracle.oauth.tk_context: "resource_access_tk",
 exp: 1425427219000,
 aud: [
  "http://www.example.com"
 ],
 prn: "tenantAdminUser",
 jti: "fa46cc79-91ab-4553-96d4-a4aef1c8ffc7",
 oracle.oauth.client_origin_id: "303a2492-d64f-4e04-b78f-b4330047312b",
 oracle.oauth.scope: "http://www.example.com",
 user.tenant.name: "OAuthTestTenant125",
 oracle.oauth.id_d_id: "13463675138302566"
}.
[signature]

Audience and scope claims in the output:

The audience claim in an access token always contains the API path of the resource. The oracle.oauth.scope claim contains the valid API path with the scope in the response. In the example above, the incoming request has a scope of http://www.example.com. The client audience configuration also has a value of http://www.example.com. The OAuth token service validates the incoming request scope with the value in the client audience configuration values. If this is a valid request, then the OAuth token service sends a valid access token response. In this case, both the audience claim and scope have the same value of http://www.example.com.