Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
BogdanF
Partner - Contributor II
Partner - Contributor II

Natural Language API and Section Access (SaaS)

Hi, all. I want to use this API: https://qlik.dev/apis/rest/questions/.
But my apps have the "section access" and different users should get different answers.
How to do it?
Labels (2)
6 Replies
alex_colombo
Employee
Employee

Hi @BogdanF , you have to authenticate using the correct user for leveraging section access rules for that particolar user. If you use a specific user, then section access will be applied and you will have answers with data filtered by section access. 

BogdanF
Partner - Contributor II
Partner - Contributor II
Author

Hello Alex. Thank you for your response.
According to the documentation, I use Api-key for authenticate "Authorization: Bearer <API-key>".
How can I authenticate a user? Can I use JWT? Do you have an example?

alex_colombo
Employee
Employee

If you will use API-Key, you cannot authenticate with your users and section access will not be applied.

You have to authenticate using OAuth with impersonation, or JWT. Here some info.

BogdanF
Partner - Contributor II
Partner - Contributor II
Author

I know JWT. I use it to authenticate users in the Qlik Cloud.
But are you sure I can use it in "Natural Language API" (https://qlik.dev/apis/rest/questions/)?
"Authorization: Bearer <JWT-Token>"?
Here I found it:
"
The Natural Language API does not check section access controls in the app's load script. If an audit administrator has the Developer role and can open apps (as provided through the space permissions), they can view the app usage metrics.
"?

alex_colombo
Employee
Employee

Yes, you should be able to use it. Try to generate a JWT token and then attach it to the header of your REST API call. You should be able to authenticate.

BogdanF
Partner - Contributor II
Partner - Contributor II
Author

It looks like it's not working.
I'm testing using curl.
When I used this: curl https://MyTenant.eu.qlikcloud.com/api/v1/questions/actions/ask -X POST -H "Authorization: Bearer <API-KEY>"....
I received the correct JSON response.


But when I used this: curl https://MyTenant.eu.qlikcloud.com/api/v1/questions/actions/ask -X POST -H "Authorization: Bearer <JWT-Token>"....
I received:
"
<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx</center>
</body>
</html>
"
The JWT token is probably correct because it works outside the API.
What else can I check? Is there an example of using JWT with the Qlik API somewhere?