9 My Profile

As a mobile app developer, you use the My Profile API to access and update details about the currently authorized user.

User Types

The information that the API returns depends on what type of user you are inquiring about. Here are the types of users:

  • IDCS users: These users have accounts that are managed by the domain’s Oracle Identity Cloud Service (IDCS) as described in Mobile Users and Roles.

  • Virtual users: These users pass a third-party token for authorization as described in Enterprise Single Sign-On.

  • Social users: These users have logged into the app from Facebook, as described in Facebook Login.

Get User Profile Information

If your app needs user information, such as full names and roles, you can call the User Profile API to get that information from their profile.

You have two options for getting a user’s profile:

  • You can make a direct REST call as described in this topic and detailed in the Oracle Mobile Cloud REST API Reference.

  • You can call the ums.getMe(httpOptions) method from a custom API implementation.

To get the currently authorized user’s profile via a direct REST call, send a GET request to /mobile/platform/users/me. Here’s an example of using cURL to send the request:

curl -i \
-X GET \ 
-u joe.doe@example.com:mypass \
-H "Oracle-Mobile-Backend-ID: ABCD9278-091f-41aa-9cb2-184bd0586fce" \
https://fif.cloud.oracle.com/mobile/platform/users/me
The contents of the response body depends on the user type:
  • When the user is an IDCS user, the response contains the IDCS user information, including roles.

  • When the user is a virtual user, the response contains the user name and roles.

  • When the user is a social user, the response contains the user's mobile ID.

Here’s an example of a response for an IDCS user:

{
  "idcsCreatedBy":{
    "type":"App",
    "display":"instance1",
    "value":"346373e8a",
    "$ref":"https://myIdentity.example.com/admin/v1/Apps/3463731bd0cc43c7ba1b79a9c6e25e8a"
  },
  "id":"7e56fd80",
  "active":true,
  "displayName":"Joe Doe",
  "idcsLastModifiedBy":{
    "value":"346373e8aa",
    "display":"instance1",
    "type":"App",
    "$ref":"https://myIdentity.example.com/admin/v1/Apps/3463731bd0cc43c7ba1b79a9c6e25e8a"
  },
  "userName":"jdoe",
  "emails":[
    {
      "primary":true,
      "value":"jdoe@example.invalid",
      "type":"work"
    }
  ],
  "name":{
    "familyName":"Doe",
    "givenName":"Joe",
    "formatted":"Joe Doe"
  },
  "urn:ietf:params:scim:schemas:oracle:idcs:extension:user:User":{
    "grants":[
      {
        "value":"89d8b111",
        "grantMechanism":"ADMINISTRATOR_TO_USER",
        "appId":"346373e8a",
        "$ref":"https://myIdentity.example.com/admin/v1/Grants/89d80073ae7f48838798cc864031b111"
      }
    ],
    "appRoles":[
      {
        "value":"a31245f1dd",
        "adminRole":false,
        "legacyGroupName":"instance1.ReadWriteRole",
        "appId":"346373e8a",
        "appName":"instance1_app_name",
        "display":"ReadWriteRole",
        "$ref":"https://myIdentity.example.com/admin/v1/AppRoles/a31245ce4ed94d2a8563d39cd888f1dd"
      }
    ],
    "accounts":[
      {
        "appId":"346373e8a",
        "value":"3819e1be",
        "active":true,
        "$ref":"https://myIdentity.example.com/admin/v1/AccountMgmtInfos/3819dd966cf34aa593df61809d62e1be"
      }
    ]
  },
  "schemas":[
    "urn:ietf:params:scim:schemas:core:2.0:User"
  ]
}

Here’s an example of a response for a virtual user:

{
  "userName":"jdoe",
  "urn:ietf:params:scim:schemas:oracle:idcs:extension:user:User":{
    "appRoles":[
      {
        "display":"FIF_TECHNICIAN"}
    ]
  }
}

Here’s an example of a response for a social (Facebook) user:

{
  "userName": "1 :623:165"
}

Get Specific User Information

If your app needs just some pieces of user information, you can call the User Profile API to get that information from their profile.

To get the information you can call the ums.getUser(options, httpOptions) method from a custom API implementation.

The contents of the response body depends on the user type:
  • When the user is an IDCS user, the response contains the fields that are specified in options.fields, or, if the options.fields property isn't provided, it contains the IDCS user information, including attributes.

    You can specify that the response contains the values for the following fields:
    • id
    • email
    • firstName
    • lastName
    • username
    • attributes
  • When the user is a virtual user, the response contains the user name.

  • When the user is a social user, the response contains the user's mobile ID.

Here’s an example of using this method to get an IDCS user’s first and last name:

{
  req.oracleMobile.ums.getUser({fields: 'firstName,lastName'}).then(
  function (result) {
    res.status(result.statusCode).send(result.result);
  },
  function (error) {
    res.status(error.statusCode).send(error.error);
  }
);

This example shows the response:

{
  "firstName": "Joe",
  "lastName": "Doe"
}

Update User Profile Information

If your app needs to update an IDCS user's information, such as first name, last name, email, you can call the User Profile API to update that information in their profile.

Call the ums.getMe(httpOptions) method from a custom API implementation and specify the fields to update.

Here’s an example of calling this method to update the user’s last name and custom attribute:

service.put(
  '/mobile/custom/incidentreport/customer',
  function (req, res) {
    req.oracleMobile.ums.updateUser(
      {
        lastName: req.body.lastName,
        urn:ietf:params:scim:schemas:idcs:extension:custom:User:custom_attribute: req.body.customAttribute
      }).then(
      function (result) {
        res.status(result.statusCode).send(result.result);
      },
      function (error) {
        res.status(error.statusCode).send(error.error);
      }
    );
  });