Okta Workflows tutorial: Import users from Google Sheets and create users in Okta

About the Author

Max Katz

Staff Developer Advocate, Okta Workflows

Max Katz is a Staff Developer Advocate for Okta Workflows. Max loves the no-code automation space and creating educational content. Before Okta, Max led the North America Developer Advocacy team at IBM. Before IBM, Max led developer advocacy for a cloud-based mobile app platform, Appery, helping it grow from zero to over 400,000 developers. Max regularly writes on his http://maxkatz.net blog. 

29 1월 2024 Time to read: ~

A woman wearing an orange shirt is seated outdoors, working on a laptop at a small table

In this step-by-step tutorial, you will build a flow that imports users from a Google Sheets spreadsheet and creates new users in Okta.

Things you will learn:

  • How to connect and import data from Google Sheets.
  • How to use a helper flow to create for-each logic.
  • How to create users in Okta.
  • How to test individual cards and the flow.
  • How to set up a flow to run on schedule.

The automation you will build has two flows.

The first flow runs on schedule and imports users from a spreadsheet:

An Okta Workflows interface displaying a scheduled flow reading user data from Google Sheets and passing it to a list iteration step. Import user flow.

The second flow creates a user in Okta from the spreadsheet:

Okta Workflows interface showing mapped fields from Object Get Multiple card to create a user in Okta with Activate set to False. Create user flow.

What is Okta Workflows? 

Okta Workflows is a no-code platform that allows you to build automations to help with identity processes. For example, you can build the following workflows without asking IT or developers for help:

  • Reset password end user sessions when suspicious activity is detected.
  • Give or remove user access to applications.
  • Send notifications (Slack, email) when events occur in your Okta organization.
    • In this tutorial, you will run a low when a user is suspended event occurs.
  • Create basic reports.

This is a short list of what is possible.

Getting access to Okta Workflows

To complete this tutorial, you need to have access to Workflows.

There are two ways to access Workflows:

  1. You might be entitled to Workflows if you already use some Okta products.
  2. Access to Workflows as part of the WIC (Workforce Identity Cloud) trial.

Workflows when using other Okta products

If you have Okta SSO (Single Sign-On) or Okta UD (Universal Directory), you might be entitled to Workflows. Check if you can access Workflows by going to Okta organization > Admin > Workflows > Workflows console.

If you use these products but don’t have access to Workflows, please contact your account manager. Or, contact me, and I will try to help you.

Okta Workflows as part of the WIC (Workforce Identity Cloud) trial

To sign up for a WIC trial:

  1. Go to the Okta Workforce trial page.
  2. Register for the WIC trial to access Workflows.

Opening the Okta Workflows console

To access Workflows:

  1. Sign in to your Okta org
    • If you are using a trial, your org URL can be found in an email with the subject "Activate your Okta account".
    • It has the following format: https://trial-<ID>.okta.com.
      • For example https://trial-6093533.okta.com.
  2. Click Admin (upper right) to access the Admin console.
  3. On the right-hand side menu, click Workflows > Workflows console to open Workflows.

You will see the Workflows home page:

Workflow management dashboard showing a welcome page. Workflows home page.

Okta Workflows fundamentals

Each card represents one step in a flow.

Okta Workflows interface showing a Compose text step mapped into a Length function step. A flow with two steps.

A card has two types of fields: input and output. Input fields accept values. Output fields are the values a card produces, which can be passed to subsequent cards

This is an example of the Text – Length card:

User interface showing a text input field labeled Length. Text - Length card.

This card calculates and returns the number of characters in a text string.

  • The text field is the card’s input
  • The length field is the card’s output (the lower grey area)

There are two types of cards:

  • App action cards are steps that control other applications or web services. For example, Gmail, Slack, and Jira.
  • Function cards are steps to interact with, change, or control the data in a flow. Examples of Function cards:
    • True/False: Evaluate values based on true or false conditions
    • Flow Control: Manage and manipulate the structure of your flow
    • Date & Time: Parse and manipulate times and dates
    • List: Create and iterate over lists of items
    • Number: Perform mathematical operations
    • Text: Build, modify, and parse text

Building the import users flow (part 1)

The Import Users flow reads all users from a Google Sheets spreadsheet. The flow then passes every user to a helper flow to create a new person in Okta.

Creating the flow

  1. In the Workflows console, click Flows.
  2. In the Default Folder, click + New Flow to create a new flow.
  3. Click Unnamed (upper left corner).
  4. For name, enter Import Users.
  5. For Description, enter This flow imports users from a Google Sheet.
  6. Also, check the Save all data that passes through the Flow? checkbox. You will be using this capability at the end of this tutorial.
  7. Click Save to save the flow name and description.
A workflow builder interface titled Import Users in the Default Folder. A new flow.

Creating a spreadsheet with new users

  1. Create a Google Sheets spreadsheet called New Okta users
    • Make sure the first row holds the column names.
Spreadsheet titled New Okta users displayed in a web-based interface Spreadsheet with new users.

How to start (trigger) the flow

There are several ways to trigger a flow:

  • Event
    • For example: run a flow when a new user is activated.
  • Schedule
    • For example: run a flow every Monday at a specific time.
  • API endpoint
    • For example: an external system calls an API that triggers a flow.

In this tutorial, you will use the Schedule option. You will configure it at the end of the tutorial.

Reading data from a Google Sheets spreadsheet

In the first step, you are going to read all the rows using the Google Sheets – Read All Rows card.

Adding the Google Sheets – Read All Rows card

  1. Click Add app action in the second box (Then do this).
  2. Find and select the Google Sheets connector.
  3. Find and select the Read All Rows action. You can also search for it.
  4. Click + New Connection to create a connection to Google Sheets. If you have an existing connection, you can use it.
Google Sheets Read All Rows connection card dialog in Okta Workflows. The Google Sheets – Read All Rows card.

Setting up a connection to Google Sheets

  1. For the Connection Name field, keep the default Google Sheets name or enter another name.
  2. Click the Create button to continue.
  3. Choose a Google account to use for this connection.
  4. Click the Allow button to create the connection.

Configuring the Google Sheets - Read All Rows card

  1. For the Spreadsheet name, select the Okta new users spreadsheet.
  2. For the Worksheets, select Sheet1.
  3. You don't need to change any other fields.
  4. Click Save.
  5. On the next view, you choose what output fields to show. You want to show all of them. Click the Save button.
  6. Click the flow Save button to save all the changes.

The Import Users flow with the Read All Rows card:

A workflow automation builder interface featuring a Google Sheets module in the center. Import users flow.

Testing the Google Sheets – Read All Rows card

In Workflows, you can test a card individually.

  1. Click ▶️ on the bottom of the card.
  2. Click Test to test the card.

Testing the Read All Rows card returns three users from the Google Sheets spreadsheet.

A workflow testing dialog displaying JSON data outputs including email, first name, last name, and row number extracted from Google Sheets. Testing the Read All Rows card.

If you expand a user, you will see the following JSON object:

{
  "Columns": {
    "2-Email": "mary@atko.email",
    "0-First name": "Mary",
    "1-Last name": "Green"
  },
  "Row Number": 2
}

Testing the flow

  1. Click the Run button to test the entire flow.

The view switches to the Execution History tab, where you can see the flow run:

A software interface displaying an execution history panel alongside a Google Sheets step output Testing the Import Users flow.
  1. Click the Run button again.

You now have two flow executions. You can switch between them to see the date for each run.

Software interface displaying a workflow execution history alongside a Google Sheets data output panel. Testing the Import Users flow.

Building a helper flow to create a user

A helper flow is a flow that another flow calls. You will use a helper flow to create a new user from the list.

Creating a flow

  1. Click on the Default Folder above the Import Users flow name to go back to the folders view.
  2. Click + New Flow to create a flow.
  3. Click on Unnamed (top left) to enter a flow name.
  4. For Flow Name, enter Create user.
  5. For Description, enter This flow creates a user in Okta.
  6. Check the Save all data that passes through the Flow? checkbox. You will be using this capability at the end of this tutorial.

Setting up the helper flow

A flow becomes a helper flow when the first card is the Helper Flow card.

  1. In the first card, click Add event.
  2. In the Okta Apps section, click on Helper Flow. You have now set up a helper flow.
Okta Workflows interface showing an On Demand Helper Flow card with context fields alongside options to add an app action or function. The Create User flow.

Setting up helper flow inputs

The helper flow accepts inputs from the main flow. To set up inputs:

  1. In the Helper Flow card, click inside the top box and enter User. Click Enter.
  2. You need to change the field type to an object. Place your mouse over the field box, open the list under Aa, and choose Object.
GIF showing the step-by-step setup of an input field on an Okta Workflows Helper Flow card. Creating helper flow input.

When a user is passed to the helper flow, its JSON object will look like this (you saw the same JSON above):

{
    "2-Email": "mary@atko.email",
    "0-First name": "Mary",
    "1-Last name": "Green"
}

You need to retrieve the 0-First name, 1-Last name, and 2-Email fields to create a new user.

Getting values from a JSON object

The Object - Get Multiple card allows getting multiple values from a JSON object.

  1. In the second box, click Add function.
  2. Select the Object category.
  3. Find and click the Get Multiple function.

To pass the User object to the Get Multiple card:

  1. Click the User object from the Helper Flow card and drag it to the object field in the Get Multiple card.
GIF of Okta Workflows interface showing a Helper Flow card configured alongside an Object Get Multiple function card. Passing data to a card.

Now you need to specify the keys for which you want to get values.

  1. In the Get Multiple card output section, click inside the field box, type 0-First name, and click Enter.
  2. Repeat the same steps to add 1-Last name and 2-Email fields.

The flow now looks like this:

An automated workflow step displaying input data passed from an On Demand Helper Flow into an Object Get Multiple card to extract user attributes. Getting user information with the Get Multiple card.

Testing the Get Multiple card

{
    "2-Email": "mary@atko.email",
    "0-First name": "Mary",
    "1-Last name": "Green"
}
  1. Click ▶️ on the Get Multiple card.
  2. For the object field, paste the sample JSON object from above.
  3. Click Test.

Testing the helper flow

  1. Click the Run button to test the flow.
  2. For the User field, enter the same sample JSON object.
  3. Click Run Test.
An automated workflow execution view displaying green success checkmarks for helper flow input parsing and user attribute extraction. Testing the Create User flow.

You can change data in the JSON object and run the flow again. You can see different flow runs with different data.

Creating a user with the Okta – Create User card

You will use the Okta – Create User card to create a user.

  1. Click Add app action to add the next flow step.
  2. Find and click on Okta.
  3. Find and select the Create User action (you can also search for it).

Obtaining API Credentials

Before setting up the connection, retrieve your OAuth credentials:

  1. From Workflows, click the four squares (upper right corner) and select Okta Dashboard.
  2. Open the Admin console.
  3. Navigate to Applications > Applications, select the Okta Workflows OAuth application, and open the Sign On tab. You will need the information from this page in the next step.

Connecting to Okta

  1. Return to the Workflows tab and click + New Connection.
  2. For Connection Nickname, keep Okta.
  3. For Client ID, copy and paste the Client ID from the page you opened in the last section.
  4. Repeat the same steps for Client Secret.
  5. For Domain, enter trial-<ID>.okta.com (without the http://). For example: trial-6093533.okta.com.
  6. Click Create.

Configuring Card Options

  1. For the Option field, select without Credentials and click Save.
  2. On this view, you can set what fields to show on the card. Keep the default values and click Save.

Next, you need to pass data to the Create User card.

Create the following connections:

Okta Workflows interface showing fields mapped from a helper flow and Get Multiple card to an Okta Create User step. Passing data to the Create User card.

Testing the Create User card

If you would like, you can test the Create User card.

  1. Click the ▶️ on the Create User card.
  2. Enter sample user information and click Test to test the card.
  3. A user is created in Okta. To see the new user, in the admin console, navigate to Directory > People.

Testing the helper flow

You can also test the entire flow.

  1. Click the flow Run button to test this flow.
  2. The JSON is pre-filled. If not, paste the JSON used above.
  3. Click Run Test.
Okta Workflows builder view with a flow simulation pop-up containing sample user JSON payload. Testing the helper flow with simulated data.
An automated workflow execution log displaying successful card steps for user creation alongside a list of past execution statuses. Flow test with simulated data.

To see the new user, in the admin console, navigate to Directory > People.

Okta Admin Console view displaying user management and directory people listings. New user.

Now that you know the helper flow works, you can finish building the Import Users flow.

Deleting users

Before you do that, delete the user(s) you created. When you test the complete flow, you will get an error if a user exists.

You will get an error message if creating a user who already exists in your organization:

An automated user provisioning workflow displaying a 400 Bad Request error during the Okta Create User step. User exists error message.
  1. Click the user name.
  2. Select More Actions > Deactivate > Deactivate.
  3. Click Delete > Delete to delete the user.

Building the import users flow (part 2)

Open the Import Users flow.

Processing the list

You need to pass each user from the list to the Create User flow.

  1. Click Add function.
  2. Go to the List category and click on the For Each function.
Okta Workflows diagram showing Google Sheets - Read All Rows card connected to a List - For Each helper flow card. Adding the For Each card.
  1. Connect the Rows field to the list field on the List – For Each card.
  2. Click Choose Flow to choose a helper flow to process each record in the list.
  3. Click the Default Folder and choose the Create User helper flow.
  4. In the With the following values section, for the User field, click the arrow on the right side, and select Item > Columns. This passes each user's information (as JSON) to the helper flow.
Okta Workflows diagram connecting a Google Sheets "Read All Rows" card to a "List - For Each" card to run a "Create user" helper flow. Passing data to the For Each card.

Testing the completed flow automation

  1. Open both flows in different browser tabs next to each other. To open the helper flow, you can click the arrow next to the helper flow name:
Okta Workflows diagram showing the Google Sheets "Read All Rows" card outputting data into a "List - For Each" card, running a "Create user" helper flow with concurrency set to 1, with an orange arrow highlighting the flow button. Opening the helper flow.
  1. Check that both flows are turned on:
User interface panel for configuring a flow, with a toggle indicating that the flow is ON. Turning the flow on.
  1. In the Import Users flow, click Run to test.

In the Execution History tab, the Import Users flow runs one time:

Okta Workflows execution history dashboard showing completed runs for a Google Sheets "Read All Rows" card connected to a "List - For Each" card executing a "Create user" helper flow. Import Users execution history.

The Create User flow runs three times, once for each user in the spreadsheet:

An automated workflow execution log displaying green success checkmarks for an On Demand Helper Flow, Object Get Multiple card, and Okta Create User step. Create User execution history.

Viewing different flow executions

Since you enabled the Save all data that passes through the Flow option, you can select a different flow execution and see the data passed in that flow run.

Setting up a schedule to run the flow

The last remaining step is to set up to run the flow on schedule.

  1. In the Import Users flow, click Add event in the first card.
  2. Choose the Schedule card.
  3. Set the schedule you need this flow to run and click Save.
    • The Summary field shows when the flow will run.
Software interface dialog titled Flow Schedule displays options for configuring an automated workflow. Setting flow schedule.

The flow on button shows when the flow will run next:

A user interface toolbar with buttons labeled Save and Run. Flow next run.

The Import Users flow with the Schedule card:

Okta Workflows interface showing a Scheduled Flow, Google Sheets Read All Rows card, and List For Each card configured to run a Create User helper flow. The final Import Users flow with the Schedule card.

To edit the schedule, click the 🕔 on the Schedule card.

To test the schedule, set the flow to run every five minutes.

Note: You need to delete users in the admin console between flow runs.

Okta Workflows Flow Schedule pop-up showing frequency and timezone settings. Running the flow every five minutes.

Things you learned

In this tutorial, you learned how to build a complete flow:

  • How to connect and import data from Google Sheets.
  • How to use a helper flow to create for-each logic.
  • How to create users in Okta.
  • How to test individual cards and the flow.
  • How to set up a flow to run on schedule.

The final Import Users flow:

Okta Workflows interface showing a Scheduled Flow, Google Sheets Read All Rows card, and List For Each card configured to run a Create User helper flow. The Import Users flow.

The final Create User flow:

A software workflow interface displays a sequence of connected modules for creating a user account. The Create User flow.

Okta Workflows resources

About the Author

Max Katz

Staff Developer Advocate, Okta Workflows

Max Katz is a Staff Developer Advocate for Okta Workflows. Max loves the no-code automation space and creating educational content. Before Okta, Max led the North America Developer Advocacy team at IBM. Before IBM, Max led developer advocacy for a cloud-based mobile app platform, Appery, helping it grow from zero to over 400,000 developers. Max regularly writes on his http://maxkatz.net blog. 

Continue your Identity journey