Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
bwisealiahmad
Partner - Specialist
Partner - Specialist

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
petter
Partner - Champion III
Partner - Champion III

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.

View solution in original post

5 Replies
bwisealiahmad
Partner - Specialist
Partner - Specialist
Author

Any ideas petter-s‌?

petter
Partner - Champion III
Partner - Champion III

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
Partner - Specialist
Partner - Specialist
Author

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.

petter
Partner - Champion III
Partner - Champion III

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.

freinholdson
Partner - Contributor III
Partner - Contributor III

Hi,

@bwisealiahmad: Do you have some sample code to get the REST API connector working with SuperOffice?

@petter: The QVW you shared fails to load when I open it with QV Desktop. Maybe a version problem? Could you maybe share a new version or just the script part?

Thanks!