Qlik Community

Qlik Sense Data Connectivity

Discussion board where members can learn more about Qlik Sense Data Connectivity.

bwisealiahmad
Valued Contributor

Automating retrieval of access tokens from a REST API

Hi,

I am trying to automate the retrieval of access tokens from the Super Office Online API.

From what I have understood what I need to do is:

  1. Send a GET request using a token identifier to super office which is authenticated which gives me a access token.
  2. Note when the token expires and then do a POST request with a update key to update the access token.
  3. Fetch new access token and use this next time it is needed to fetch data.

Now I haven't done anything similar, but I have managed to do it somewhat with Qlik Sense and creating a web page that gets the access token back using a local hosted webpage on a webservice. Now I want to do it using Qlik Sense and want to understand if that is possible and how?

The syntax for retrieving the access token with super office is:

https://online.superoffice.com/login/common/oauth/authorize?response_type=token &client_id=670734e0-4c5a-11e3-be9e-a171392e81db &redirect_uri=https://example.com/spa/

So the access token is returned at the URL defined after redirect_uri.

Any suggestions or ideas is appreciated.

Best,

Ali

1 Solution

Accepted Solutions
MVP
MVP

Re: Automating retrieval of access tokens from a REST API

The trick is to first read the access token by making sure that you select also the headers where the access token most likely is returned.

Then you have to get it out of the table by using Peek and a variable.

Lastly you can use variable through $-sign expansion or directly to include the token in subsequent requests either in the the connection string or via the SQL command of the REST connector inside the WITH CONNECTION part of the SQL.

I have a QlikView QVW that was part of a proof-of-concept for doing this against some other API that wasn't SuperOffice. I have attached it.

4 Replies
bwisealiahmad
Valued Contributor

Re: Automating retrieval of access tokens from a REST API

Any ideas petter-s‌?

MVP
MVP

Re: Automating retrieval of access tokens from a REST API

Yes - I did something similar back in August last year. Not with the SuperOffice API but with another product which needed the same approach as a demo. I'll see if I can find the info later.

bwisealiahmad
Valued Contributor

Re: Automating retrieval of access tokens from a REST API

Ok.

I've managed to return the access token to a localhost site I've made and hosted with xampp which returns  the access token, but I can't seem to figure out how to return that type of response directly in Qlik Sense. To get the access token returned in some format in Qlik Sense so that I can keep everything within Qlik.

MVP
MVP

Re: Automating retrieval of access tokens from a REST API

The trick is to first read the access token by making sure that you select also the headers where the access token most likely is returned.

Then you have to get it out of the table by using Peek and a variable.

Lastly you can use variable through $-sign expansion or directly to include the token in subsequent requests either in the the connection string or via the SQL command of the REST connector inside the WITH CONNECTION part of the SQL.

I have a QlikView QVW that was part of a proof-of-concept for doing this against some other API that wasn't SuperOffice. I have attached it.

Community Browser