Skip to main content

Read Okta user

In this step we will configure an action to read an Okta user. This is required in order to get the user ID that is used as an input into Okta's FIDO Pre-reg API.

Before you proceed ensure that you have configured the connection alias and credential used for calling the Okta API with your API token.

Action properties

On the ServiceNow home screen, search for flow designer.

Click Flow Designer, a new window should open.

Configuration menu

Once the Flow Designer page opens, click the Create new button, then select Action.

Configuration menu

A menu will appear to configure the action's properties. Use the following values to initialize your action.

  • Action name: Okta Read User
  • Application: YubiEnterprise Delivery App
  • Description: Read a user object using Okta's API

Configuration menu

Click Submit.

Action inputs

Next we are going to configure the inputs that go into the action. These inputs are the parameters that are going to be passed into our API call by our flow.

For each row in the table below, perform the following steps:

  1. Click the +Create Input button at the top.
  2. Fill in the input using the data provided below to the corresponding field (note that name will be automatically input).
LabelTypeMandatory
User LoginStringon

Your actions input menu should look like the example below.

Inputs menu

Click Save once your inputs are complete.

API REST call

Next we will configure the action step for making the REST HTTP call to Okta's API.

On the left side, in the Action Outline, click the bottom blue + button.

Add second action

Search for rest and select the REST option

note

If the REST option does not appear then you have not activated the IntegrationHub plugin. Follow the instructions in the prerequisites section.

Inputs menu

Connection details

First we will add our API credentials to the REST call. We will utilize the connection alias that was created earlier in this guide.

Ensure that the Connection field is set to Use Connection Alias.

Change the Connection Alias to the Okta option created earlier in the guide. The Base URL should be set automatically based on the connection alias.

Your connection details should look like the example below.

Connection details final

Request details

Next we will configure the details of the API method call. We will be utilizing the GET /api/v1/users/{id} API method

Configure the Request Details section with the following values:

  • Build Request: Manually
  • Resource Path: Type /api/v1/users/ then drag the User Login data pill to the end of the url (see the image below for an example)
  • HTTP Method: GET

The Headers should include two header properties using the values below

NameValue
Acceptapplication/json
Content-Typeapplication/json

Your request details should look like the example below.

Request details final

Click Save once your request is complete.

Output script

We will now create a script to extract the user ID from the REST Step's request body.

On the left side, in the Action Outline, click the bottom blue + button. Action outline 3

Search for scripts and select the Script option

Script action step

Script inputs

We'll start by creating the input for the script. We will only create one input, which will be the result of the previous REST step call

  1. Click the +Create Variable button
  2. Name: responseBody (case sensitive)
  3. Value: Drag the Response Body data pill from the REST step section on the right side of the menu

Your script inputs menu should look like the example below.

Script action step

Adding the script

Next we are going to add a script to Script field. Copy the script provided below into the Script field.

(function execute(inputs, outputs) {
const response = JSON.parse(inputs.responseBody);
outputs.user_id = response.id;
})(inputs, outputs);

Script outputs

Lastly, we will add the output variables for the script

For each row in the table below, perform the following steps:

  1. Click the +Create Variable button at the bottom.
  2. Fill in the input using the data provided below to the corresponding field (note that name will be automatically input).
LabelTypeMandatory
user_idStringon

Your script outputs menu should look like the example below.

Script outputs

Click Save once your output script is complete

Action outputs

Lastly we will define the outputs of the action, which will only be the user ID.

We will start by clicking the Outputs tab in the Action Outline pane.

Action outline outputs

Next we are going to configure the outputs.

For each row in the table below, perform the following steps:

  1. Click the +Create Output button at the top.
  2. Fill in the input using the data provided below to the corresponding field (Note: Unlike the previous examples, the Name field is not auto-populated).
LabelNameTypeMandatory
User IDuser_idStringon

Your actions outputs menu should look like the example below.

Inputs menu

Once complete, press the Exit Edit Mode button on the top of the menu.

A new menu should appear showing the outputs you just defined with empty Value fields. For each output, you will add a data pill from the Script step section on the right side of the menu

Use the table below to correlate the correct data pill to a label.

LabelSection > Data pill
User IDScript step > user_id

Your actions outputs menu should look like the example below.

Inputs menu

Click Save once your outputs are complete

Publish the action

If everything looks good, click the Publish button at the top of the action menu to make the action available for all flows.