Cumulocity IoT SSO Integration with Okta
Tags: iot, integration, okta, openid
Published: 2021-09-24 08:40:57

---
title: Cumulocity IoT SSO Integration with Okta
published: true
date: 2021-08-25 19:40:05 UTC
tags: #iot, #integration, #okta, #openid
canonical_url: https://tech.forums.softwareag.com/t/cumulocity-iot-sso-integration-with-okta/243854
---

Cumulocity IoT can integrate with Okta as an identity provider (IDP) using OpenID Connect. The connection can be made with out of the box functionality from both Cumulocity IoT and Okta. This document will guide users through the process of making the initial integration.

## Prerequisites

1. Cumulocity IoT tenant with access to the Administration application and permissions to modify Authentication settings
2. Okta account with permissions to create custom applications and custom authorization servers

## Okta Setup

1. Log into the Okta console and navigate to the Applications page  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/3/4/3467a0e344780d22271f5166cb792a81e0032276.png)
2. Click “Create App Integration” and choose a Sign-in method of “OIDC-OpenID Connect” and Application type of “Web Application”  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/3/f/3fefa188106059aaec66833793d7f7df5252b86c.png)
3. Fill out the form using the following guidelines:  
a. **App integration name** : This can be whatever you want it to be, since it is only referenced in the Okta console  
b. **Grant type** : The only boxes checked here should be “Authorization Code” and “Refresh Token”  
c. **Sign-in redirect URIs** : Provide the URL that your Cumulocity IoT tenant uses for redirects, which is in the format of /tenant/oauth (e.g., [https://tenant123.us.cumulocity.com/tenant/oauth](https://tenant123.us.cumulocity.com/tenant/oauth))  
_Note: You can also find the Redirect URI in the Cumulocity IoT tenant’s Single sign-on configuration page_  
d. **Controlled Access** : Click on the appropriate permissions you wish to give for other Okta users to access this application
4. Save the newly created application
5. Within the new application:  
a. Navigate to the “General” menu and make note of the “Client ID” and “Client Secret”  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/8/8/88f94d5bcc67f6ce9fbd706fe4b47597734c536d.png)  
b. Navigate to the “Assignments” menu and add any users that you want to be able to log in to Cumulocity IoT using Okta SSO
6. Navigate to “Security → API settings”  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/e/4/e43fc1577dd23cc6894a41b9777ed0bda4c986ef.png)
7. Click the “Add Authorization Server” button to create a new custom authorization server
8. Fill out the “Name”, “Audience”, and “Description” with any names you would like to use and click “Save”  
_Example:_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/1/a/1a7b4d7f0e5b420d0e7259f6c50c3127119f9a21.png)  
b. Note: Remember the “Audience” value here because you’ll need it later for the Cumulocity IoT setup
9. Within the new authorization server, navigate to the “Scopes” menu and click “Add Scope”  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/0/b/0bd38cad2ef27bffc37081c180e528df7b89c0c9.png)
10. Fill out the “Name”, “Display phrase”, and “Description” fields while leaving all checkboxes unchecked and click “Create”  
_Example:_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/b/c/bc97e336af3f94097750aefc1b12d57eb49a7b38.png)
11. Still within the authorization server, navigate to the “Claims” menu  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/4/6/467a112c78e895dc4fb23ed18ac0fcd697bf72de.png)
12. Use the “Add Claim” to add any of the user information needed from the screenshot above, which will be included in the JSON Web Token (JWT) that is returned to Cumulocity IoT  
_Example:_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/7/1/71eecd8c9067804c7b3cbc9a925b87ac0d56700b.png)  
_Note: For more user info options to include in these claims, refer to the Okta Expression Language overview documentation_
13. Save your new claims and, still within the authorization server, navigate back to the “Settings” menu and click on the “Metadata URI” link  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/a/8/a8f6936a8cd139f58832230690964a6915f39664.png)
14. An Okta metadata JSON document will display on the screen, which you should save for later use during the Cumulocity IoT setup

## Cumulocity IoT Setup

1. Log into your Cumulocity IoT tenant with an admin account, and Navigate to the “Administration” application, and then the “Settings  Authentication  Single sign-on” screen and choose a template of “Custom”  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/2/3/23cdb70314613b235dc197d66108835456e27ecc.png)
2. Scroll down to the “Basic” section and enter the following values in the form  
a. **Redirect URI** : Leave as default value  
b. **Client ID** : Okta application client ID mentioned in step 5a of the Okta setup  
c. **Button name** : The text you want to see on the login screen button (Example: “Login with Okta SSO”)  
d. **Token issuer** : The “token\_endpoint” URL listen in the Okta metadata JSON document  
e. **Audience** : Value for audience mentioned in step 8 of the Okta setup  
f. **Provider Name** : Use “Okta”  
g. **Visible on Login Page** : Check this option
_Example:_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/e/e/eed663f3eb3bf9b795a8b3109c6a27ea19d2ff4c.png)
3. Scroll up to the “Authorization request” form and enter the following values into the form  
a. **URL** : The “authorization\_endpoint” URL from the Okta metadata JSON document  
b. **Headers** : N/A  
c. **Request Parameters** : Add request parameters for the following variables  
**response\_type** : code  
**redirect\_uri** : ${redirectUri}  
**state** : state-296bc9a0-a2a2-4a57-be1a-d0e2fd9bb601  
**client\_id** : ${clientId}  
**scope** : Name of your scope provided in step 10 of Okta setup
_Example:_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/d/7/d7d0a8f9d883da66402443eb7c66549712cb41ac.png)
4. Scroll down to the “Token request” form and enter the following values into the form  
a. **URL** : The “token\_endpoint” URL from the Okta metadata JSON document  
b. **Body** : grant\_type=authorization\_code&code=${code}&client\_id=${clientId}&client\_secret=<your\_client\_secret\_here>&redirect\_uri=${redirectUri}&scope=<your\_scope\_here>  
_Note: Remember to replace the placeholder for client secret and scope in the body value_  
c. **Headers** : N/A  
d. **Request Parameters** : N/A
_Example:_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/e/9/e9a4e04d2211992951c8ccc3eddbc7dfa033fba4.png)
5. Scroll down to the “Refresh request” form and enter the following values into the form  
a. **URL** : The “token\_endpoint” URL from the Okta metadata JSON document  
b. **Body** : grant\_type=authorization\_code&code=${code}&client\_id=${clientId}&client\_secret=<your\_client\_secret\_here>&redirect\_uri=${redirectUri}  
_Note: Remember to replace the placeholder for client secret in the body value_  
c. **Headers** : N/A  
d. **Request Parameters** : Add request parameters for the following variables  
**response\_type** : refresh  
**client\_id** : ${clientId}
_Example:_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/a/e/aefb518642dea3a6238acdfa4d5fc4e2c81995c4.png)
6. Scroll down to the “Logout request” form and enter the following values into the form  
a. **URL** : The “end\_session\_endpoint” URL from the Okta metadata JSON document combined with “?redirect\_uri=${redirectUri}” (Example: _[https://dev-941791.okta.com/oauth2/aus2i41opp6UqtQb8357/v1/logout?redirect\_uri=${redirectUri}](https://dev-941791.okta.com/oauth2/aus2i41opp6UqtQb8357/v1/logout?redirect_uri=%24%7BredirectUri%7D)_)  
b. **Request Parameters** : Add request parameters for the following variables  
**client\_id** : ${clientId}
_Example:_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/6/b/6b9a14e784ae92bf6284b8fe45530debb3a86213.png)
7. Scroll down to the “Access mapping” form and use it to assign values within the JWT returned to Cumulocity IoT to roles within the tenant, which is documented here
_Example (Full Admin Access):_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/1/6/1649464a824d9ed4b7ae2050357199fd25c7051a.png)
8. Scroll down to the “User ID” form and uncheck “Use constant value”, and enter in the “JWT field” which JWT key you would like to use to match to the Cumulocity IoT username  
Note: “sub” works well as a value in this example, but you can play around with other keys by logging in with the SSO user and checking the audit logs, which shoes the full JWT
_Example:_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/0/d/0de1f75c4e6d2e8a63f0d860d286a62f994215cb.png)
9. 
Scroll down to the “Logout request” form and enter the following values into the form  
a. **Verifier** : JWKS  
b. **JWKS URI** : The “jwks\_uri” URL from the Okta metadata JSON document
_Example:_  
 ![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/2/9/29dc47a87091b815ac7fff54a9d24cbadcb7e433.png)

## Final Steps

SSO logins should now work for any user setup in the Okta application’s assignment screen (Okta setup step 5b). Your login page should look like the screenshot below, and clicking on the “Login with Okta SSO” button should redirect you to Okta’s authentication screen.

![image](https://aws1.discourse-cdn.com/techcommunity/original/3X/c/7/c751a76339e5cab3d61edfc11f48a4607d8ddf87.png)

This guide does not cover the many options available in Okta to control authorization with their IDP. For more options, reference the Okta developer guide.

[Read full topic](https://tech.forums.softwareag.com/t/cumulocity-iot-sso-integration-with-okta/243854)