Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
This article is meant to get users starting on the Oauth connector in Qlik Application Automation.
This connector is meant for advanced users to platforms where we did not (yet) build a dedicated connector for.
The connector makes use of the authorization code flow of Oauth2. The authorization code flow is well explained on the following link: https://oauth.net/2/grant-types/authorization-code/
First start by looking for the connector "OAuth2". When you click on connect it requests the following input parameters:
When all of this is provided and you click the Save button, it will open a popup taking you to the login screen where you will be prompted to provide consent. Your connection is now ready to be used.
When selecting the connector in an automation you will notice Raw API Request block. This block has the following input variables:
Apart from the above input variables, RAW API LIST blocks have the following input variables
Input variables | raw API list request - page number based paging | raw API list request - offset based paging | raw API list request - cursor token based paging |
Page Size Field Name | Yes | Yes | Yes |
Page Size | Yes | Yes | Yes |
Offset Field Name | Yes | ||
Page Start | Yes | Yes | |
Json Path For Output Records | Yes | Yes | Yes |
Json Path For Cursor | Yes | ||
Output Name For Cursor Token | Yes | ||
Page Number Field Name | Yes |
The following example will obtain tasks from the Microsoft Todo application. We do not yet have a connector to do this and Oauth is used to obtain the value for the Authorization header.
We first start by obtaining the Authorize URL, Access Ttoken URL and Refresh Token URL. From the Microsoft documentation we can find these at https://docs.microsoft.com/en-us/graph/auth-v2-user. We use the following values:
The documentation of the Microsoft Graph API can be found at https://docs.microsoft.com/en-us/graph/use-the-api?context=graph%2Fapi%2F1.0&view=graph-rest-1.0.
We obtain the Base URL: https://graph.microsoft.com/v1.0.
We will have to obtain a client ID and client secret. We can do the registration for an app at https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade. We register a new application, give it the name "Todo App" and set it to only allow accounts from this organizational directory only. For the redirect url the following value needs to be provided: https://connector.qlikcloud.com/callback. Set the platform to Web.
On the next screen you can obtain your Client ID. Copy this value. Click on Add a certificate or Secret and it will take you to a page where you can create a new client secret.
Create one and copy the value that is now visible.
In the left sidebar click on the button API Permissions. Click on Add a Permission and provide the scope Tasks.ReadWrite.
Back to your connector configuration - Provide the client ID and client secret that were obtained and for the scopes provide the following: User.Read Tasks.ReadWrite offline_access openid
Now click on Save and you should be presented with a screen to login.
1) Raw API Request block:
Create a new automation and drag the Raw API Request block on to the canvas. Set the path to /me and the method to GET. When you now execute it, you should receive a JSON result containing the keys response, headers and status. Most relevant information should be part of the response.
Next let's obtain a list of tasks. Drag another Raw API request block and put it below the earlier one. Set the path to /users/{$.rawApiRequest.response.id}/todo/lists and method should remain at GET. Now when you execute this, it will return you the lists you keep in Todo.
2) List Blocks: Depending on the type of pagination, we have 4 different List blocks. Therefore, depending on the type of pagination in API, any one of the List blocks should be used for a certain API.
We tested the blocks using four distinct APIs, each with a different pagination implementation.
The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.
Hi Mark,
As per following documentation page,
REST connector doesn't support OAuth (see page bottom).
Does you article apply only for SAAS version? I'm trying with QSEOW August 2022 and struggle getting a token with the REST connector vs OAuth2.0
Thanks
Thanks
Hello @Chotana2
The REST connector in general does not support OAuth at this point: Does Qlik REST connector support OAuth authentication?
I'd recommend looking into logging a feature request/idea (I couldn't find one already logged specifically for the REST connector).
All the best,
Sonja
Hallo Sonja,
It's already logged here
https://community.qlik.com/t5/Suggest-an-Idea/Qliksense-oAuth2-Authentication-Support/idi-p/1707486
@Chotana2 aha! I misunderstood, I thought you meant only the REST connector
Well,
My request concerns the REST connector, but it's better to open it more widely.
Hi Mark,
Thank you for this article. It helped me creating an oauth2.0 connection to MS Projects.
Yet, the connection seems to disconnect after a while. When I click on SAVE, I fill in my Username and Password. I receive the message 'Connection is linked' and everything works fine. But after a few hours the connection seems "unlinked", although the message is still 'Connection is linked'. When I run the automation it gives an 403 error. I just need change the URL and click on SAVE so I can login with the user again, but I don't want to do this all the time 🙂
Is it possible to keep the user connected?
Hi Mark,
The raw API list request - cursor token based paging should work for Microsoft Graph correct? T
I can see the @odata.nextLink skiptoken in the response body (not headers) when I do a raw API request but when I try to utilize the raw API list request - cursor token based paging block, I see the values come across but it doesn't look like its parsing out the @odata.nextLink correctly.
Any thoughts?
Thanks!