How to link Amazon Cognito with Orbita
Orbita has several built-in providers that you can configure for authentication. You can also configure third-party Oauth providers such as Social media sites including Facebook, Twitter, Microsoft, Amazon, and more. Oauth is an authorization framework specifically built for HTTP APIs that let the users grant access to an application to use their user data.
In Summary, Orbita supports account linking to any third-party system that supports the Auth Code Grant Flow of OAuth 2.0.
In this example, we will use Amazon Cognito. Amazon Cognito service is designed to provide APIs and infrastructure for key features in the user management space such as authentication, authorization, and managing user repositories with different operations for your web and mobile apps. Refer What is Amazon Cognito? - Amazon Cognito for more information.
This web service lets you add user sign-up, sign-in, and access control to Orbita.
Â
Amazon Cognito
Go to console.aws.amazon.com
Log in with your credentials when prompted.
In the AWS Management Console, under the Security, Identity, & Compliance, select Cognito.
Â
On the Amazon Cognito home screen, select Manage User Pools.
Create a user pool
Click on the Create user pool button.
Â
Give a user pool name and click on the Review defaults button.
Â
You will be navigated to the review screen. Click on the Create pool button.
Â
Your User pool is created successfully.
General Settings
App client
Select the User pool.
Navigate to the Side menu > General Settings >App clients.
Click on the Add an app client button
Give a name for the app client.
Configure the rest of the settings as you require (for this example, we use the default settings).
Scroll down to the end of the page and click on Create app client.
Note the App client id. (Client ID is a publicly exposed string that is used by the service API to identify the application and is also used to build the authorization URLs that are presented to the users.
Â
Click on the Show Details button to view the App client secret.
App Integration
App client settings
Navigate to the Side menu > App integration > App client settings.
Â
Click on the Cognito User pool check box.
Fill in the Callback URL with the chatbot endpoint.
Eg: https://sandbox15.orbita.cloud:8443/oeapi/bot/docflowUse the https://<domain-name>.orbita.cloud:8443/oeapi/logout for the Sign out URL.
Under OAuth2.0 > Allowed OAuth Flows, enable Authorization code grant and Implicit grant.
Under the Allowed OAuth scopes, check everything except the aws.cognito.signin.user.admin.
Click Save changes.
Domain name
Navigate to the Side menu > App integration > Domain name.
Â
Enter a Domain prefix and click on the Check Availability button
Â
You will be notified about the availability of the domain name.
Â
Click on Save changes.
Â
In this example, my Domain URL is https://sandbox15..auth.us-east-2.amazoncognito.com
Orbita Experience Manager
Provider Settings
Login to Experience Manager. Navigate to Global Settings and User profile menu > Settings > Provider.
Â
On the provider listing screen, click on the icon to Add a provider.
Â
Give a provider name without spaces.
In the Authorization URL field, enter the <Custom-Domain-URL>/oauth2/authorize.
In the Token URL field, enter the <Custom-Domain-URL>/oauth2/token.
Enter the App client id from Cognito.
Enter the App client secret from Cognito.
Enter callback URL. eg: https://<domain-name>.orbita.cloud:8443/api/auth/<provider-name>/callback
As we have enabled multiple scopes in Cognito > app client settings, you can provide any of those scopes here.
When an account is linked, a placeholder user is created in Orbita. The user is created using the persona type specified in the drop-down menu. Select any one of these. (In this example, we selected patient persona).
Â
Profile options will fetch and store the information of the logged-in user from the client’s database.
A Json code that contains the URL, header, method, body, and attributes is to be used in this field to get the data.
In this example, we used the below code.{ "url": "https://sandbox15..auth.us-east-2.amazoncognito.com/oauth2/userInfo", "method": "GET", "header": { "content-type": "application/json", "Authorization": "Bearer __ACCESS_TOKEN__" }, "attributes": { "id": "email", "firstName": "name", "lastName": "given_name" } }
Click on the button to save the Provider.
Adding the Provider to a Project
Navigate to the project listing screen.
Click on the verticle ellipses against the project and click on Edit.
Select the OAuth provider from the dropdown.
Â
Click on Update.
Testing the integration
Load the chatbot.
Click on the login button when prompted to log in. See How to use Login Directive
Â
When you click the Login button, you will be navigated to the Cognito authentication page in a new tab.
Â
Login with an existing account or create a new one using the Sign-up link.
If you set the user pool to require further authentication to log in, it will ask for a verification code.
Enter the verification code to get logged into the chatbot.
You will be navigated back to the chatbot upon successful authentication.
Video Content
https://cdn.orbita.cloud/assets/orbita/experiencedesigner/Authenticationproviders.mp4
Related Articles
How do I link accounts with Orbita and other third party providers?
Â