Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
i googled a while, but did not found anything clear.
Is it true, that in 2021 QLIK REST Connector is not supporting OAuth2 ?
I can't believe, as this is really a standard.
Is there any simple workaround for this?
I will NOT use Basic Auth and CAN'T use any Windows Credentials as NTLM or DIGEST
Please help!
bye!
anybody with an idea??
There is a work around, but you need to do some manual work. Don't have any examples for you, but we have had it working in the past.
Sounds good, but could you please give me some more advise. Where can i find a solution for this?
Thank you for your effort & time!
We found the solution!
You will have to create two REST Connectors in QLIK
One POST for the Token Request and one GET for the Data Request
With the Token request header information is required with
contentType=application/x-www-form-urlencoded
CharacterType=UTF8
You have to enter the Request Parameters in the form:
grant_type=password&username=xxx&password=xxx
Request the token into a QLIK table. Read out the access_token und place it in another GET Request for the data
I am also facing issues REST Connector and OAuth2.
Kindly elaborate a little briefly on how you achieved it.
Thanks,
Perumal A
Hi,
OAuth2 requires to place all credential information, username, password and token in HTTPS header instead of simple dropping it into the URL as parameter.
OAuth2 requires two HTTPS Requests.
First request is to get the token (POST), second request is to fetch the data (GET) while using the token requested before.
In QLIK, the trick is to create a simple HTTP GET Connector and to modify it's properties in code with the WITH CONNECTION Statement
Example to get the Token:
set vContentType = 'application/x-www-form-urlencoded';
set vURL = 'https://xxxx.com/api/oauth/token';
set vRequestBody = 'grant_type=password&username=x_user&password=x_pwd';
LIB CONNECT TO 'REST_POST'; <---- this is the HTTP POST Connector
RestConnectorMasterTable:
SQL SELECT
"access_token",
"token_type",
"expires_in"
FROM JSON (wrap on) "root"
WITH CONNECTION (
URL "$(vURL)",
HTTPHEADER "Content-Type" "$(vContentType)",
BODY "$(vRequestBody)"
);
[Token_Table]:
LOAD
[access_token],
[token_type],
[expires_in]
RESIDENT RestConnectorMasterTable;
Let vToken = Peek('access_token', 0, 'Token_Table');
Now you have the token in Variable vToken, let's fetch the data now in the same way:
LIB CONNECT TO 'REST_GET'; <---- GET HTTPS CONNECTOR
set vContentType = 'application/x-www-form-urlencoded';
set vURL = 'https://xxxxx.com/api/publicreport/parameter?year=2022';
set vRequestBody = '';
RestConnectorMasterTable:
SQL SELECT
"----Fieldlist....",
FROM JSON (wrap on) "root"
WITH CONNECTION (
URL "$(vURL)",
HTTPHEADER "Authorization" "Bearer $(vToken)",
BODY "$(vRequestBody)"
);
HOPE THAT HELPS!!
Thanks for your quick reply
We are using grant Type is authorzation_code not user id & password. can you help how vRequestBody need to create for this with below information
grant_type=authorzation_code
client_id= x_client_id
Client_Secret=x_client_secret
is possible to share a snapshot of what is configured in REST_POST and REST_GET.
Thanks,
Perumal A
Hi,
REST POST and REST GET is empty. It will be filled with the WITH CONNECTION.
I suppose that you'll have to place it like this:
set vRequestBody = 'grant_type=authorization_code&client_id=xxx&Client_Secret=xxx';
Try to use the first POST Request above.
I think you'll have to play around with this a little bit.
I suppose it should be defined in body, i "could" be that it must be placed in header.
PLease be aware of correct typing! It did cost me some brains, cause i had a typer in there sometime...
Hi,
Thanks for the quick response.
We are facing issues in generating a token using below request body with grant Type authorization_code
set vRequestBody = 'grant_type=authorization_code&client_id=xxx&Client_Secret=xxx';
But we tried generating a token from Postman and the token used in vToken after that it's working fine.
We trying generate dynamic token through script instead of the postman.