Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Hephaistos
Partner - Contributor
Partner - Contributor

OAUTH2 connection - Refresh Token - unable to get value

Hi,

We have an issue on connecting via Qlik Sense to an external provider.  The connection has however been verified via postman and via Qlik Sense

We know that on each refresh we have to post a different 'Refresh-Token' to get new access; whenever we do a test, the code is used to test and a new refresh-token should be entered.  It seems that on doing the save for the access code an implicit test in the background seems to be executed.

Whenever we are trying to see the result, it refreshes again, resulting in a 'NO AUTHORIZATION'...  So that means we are stuck in a loop and cannot get the 'refresh_token' value...

Is there a way to visualise the code once it is saved?  In that way we could change the script, just making sure that we are able to fetch and hold the token into our code?

Thanks for your assistance.

6 Replies
Gysbert_Wassenaar

Hephaistos
Partner - Contributor
Partner - Contributor
Author

Hi,

many thanks for your answer.  This is something we tried but is not really working.  We need to work with the refresh_token value, in a separate POST API...
this is good to receive the initial value, but we can only use this the first time.

If we are using this solution, the end-user needs to authenticate each time before the refresh towards the system; the option for authentication seems not to work at that point.

The provider specially added the refresh-token to overcome these kind of issues.  It is just working fine and giving a result, however we are unable to see and fetch that result 😞

Gysbert_Wassenaar

That doesn't sound like how oauth2 works. So either one of use doesn't understand how oauth2 works or you're talking about something else (or both). Perhaps this discussion helps: https://community.qlik.com/t5/Qlik-Sense-Data-Connectivity/REST-CONNECTOR-locate-the-Authorization-t...


talk is cheap, supply exceeds demand
Hephaistos
Partner - Contributor
Partner - Contributor
Author

The latter document you have send us, is indeed what we are looking for *only* we are looking for a solution to have this in Qlik Sense...  The document only mentions the solution for Qlikview and not Sense...

We have it working in PowerBI, where we can just edit the connection via an advanced connect, but no such thing exists in Qlik Sense.

 

/*get the token based on refresh token*/ actualUrl=URL&"/api/oauth2/token",cntnt=Text.ToBinary(Uri.BuildQueryString([refresh_token=Refresh_token,grant_type="refresh_token",client_id=client_id,client_secret=client_secret])),

options = [RelativePath = "/api/oauth2/token", Headers =[#"Content-type"="application/x-www-form-urlencoded"],Content=cntnt],

result=Web.Contents(actualUrl,options),

#"JSON"=Json.Document(result),

/*use the access_token received in previous step for the actual request */

access_token=#"JSON"[access_token],

AccessTokenHeader="Bearer " & access_token,

GetJsonQuery = (Web.Contents( URL & "/api/v1/"& Number.ToText(DivisionCode) & "/" & URI,[Headers=[Authorization=AccessTokenHeader]])), 

 

Parameters for the API can both be stored in the API screen as parameters, or they can be done as parameters within the script...
That is exactly the solution we are looking for within QlikSense.

What we are trying to do is to use the LIB Connect to from the 'refresh token', to get our data and to send a new request...
However, there doesn't seem to be a way to get the scripting behind the connect, since it is evaluating the refresh_token on every use...

Gysbert_Wassenaar

It works the same in Qlik Sense as in Qlikview. The REST Connector is the same. Except in Qlik Sense the configuration UI is integrated in the Qlik Sense UI. As the author of the solution states:


Sorry about the delay in responding. I've been playing around a bit with this in Qlik Sense as well, and I managed to alter the parameters for the connection using WITH CONNECTION, in a similar way as above. This worked even in Legacy mode (which was a surprise to me).

 


talk is cheap, supply exceeds demand
mountaindude
Partner Ambassador
Partner Ambassador

Indeed, you pretty much have to keep track of whether your refresh token has timed out or not, and then update it as/when needed. 

Björn @ Qlik support indeed describes it well at https://community.qlik.com/t5/Qlik-Sense-Data-Connectivity/REST-CONNECTOR-locate-the-Authorization-t...

This approach is confirmed to be working.

Please mark the post as a solution if it provided you with a solution to the topic at hand. Thanks!