I am trying to connect to google analytics by following this guide http://help.qlik.com/Connectors/en-US/connectors/#../Subsystems/REST_connector_help/Content/1.0/Crea...
But I get stuck on step 7. Open Developer tools in Google Chrome and locate the Authorization token
How do i locate the token?
You have mentioned as that:
To get around this I simply created two connections using the REST Connector, one for GET (LIB: Google Analytics API) and one for POST (LIB: Google Authorization) and used an open JSON server at jsonplaceholder.typicode.com wheen creating the connections (you cannot alter the Method GET/POST using WITH CONNECTION).
How did you created this connection LIB: Google Authorization and LIB: Google Analytics API using jsonplaceholder.typicode.com to create connections, Can you please explain on this. i have got all client_id, secret and refresh_token. Just i need to create conection to load data.
you don't you use:jsonplaceholder.typicode.com/posts with a post method and the qeuery parameter as title = foo in your rest connector. you Lib connect to that connection name when you run your select statement from you add a WITH CONNECTION() passing a vRequestBody,which contains all the information you need to pass to the post , ie refresh_token,redirect_uri etc, google url This then uses the new modified string as the connection instead of what was created. once you have done that you can use Karl's code for the configuration of the data into tables.
I am able to accomplish the authentication, thanks to your shared steps and example.
Just wondering what was the intention to start with
IF vTokenExpires <= now() THEN
This is what I predefine variable vTokenExpires ------ LET vTokenExpires = Timestamp(now());
Question is...do I have to store the expires_in value somewhere else in the app/database? Otherwise, in my case I am still going to request access_token every time I load the script regardless of the actual expire time. What would be the best practice to handle token expiry using Rest Connector?
Wow this was a really old post, glad it's still serving it's purpose helping people out
About the expire time / refresh token, this is related to the API being used (Google API in this case) but I'm not sure you even need to bother if you only run the script yourself (or scheduled on a QSE/QV server).
But according to the documentation on Google there is a risk to reach a limit on refresh tokens if using the same credentials (clientid/secret) on multiple clients/devices at the same time:
"Note that there are limits on the number of refresh tokens that will be issued; one limit per client/user combination, and another per user across all clients. You should save refresh tokens in long-term storage and continue to use them as long as they remain valid. If your application requests too many refresh tokens, it may run into these limits, in which case older refresh tokens will stop working. "
I guess that's what caught my attention and the reason for why I keep track on the expiration time, so I didn't request a new access token if not required.
Hello! I've read through this post quite a few times and am learning as I go, but am still having trouble. I've been able to connect to my GA data using the GET, but not with the refresh token POST connection.
Additionally I've been able to connect using the POST for the refresh token successfully as well (below)...however, I can't get them to go together now.
Here is what I currently have.
SET vClient_id = MY CLIENT ID;
SET vClient_secret = CLIENT SECRET;
SET vRefresh_token = REFRESH TOKEN;
IF vTokenExpires <= now() THEN // if access_token expired request a new one using the refresh_token
LET vRequestBody ='';
LET vRequestBodyvRequestBody = vRequestBody & 'grant_type=refresh_token';
LET vRequestBodyvRequestBody = vRequestBody & '&client_id=' & '$(vClient_id)';
LET vRequestBodyvRequestBody = vRequestBody & '&client_secret=' & '$(vClient_secret)';
LET vRequestBodyvRequestBody = vRequestBody & '&refresh_token=' & '$(vRefresh_token)';
CUSTOM CONNECT TO "Provider=QvRestConnector.exe;
FROM JSON (wrap on) "root"
WITH CONNECTION (
LET vExpiresIn = peek('expires_in',0,'access_token');
LET vAccessToken = peek('access_token',0,'access_token');
LET vTokenExpires = timestamp(now() + $(vExpiresIn)/86400);
So, what comes after this? Or before it?
This is my get URL...
Using this in Qlikview desktop.
I need you help.
I am creating connection to AFAS.
I have URL and Authentication Token.
But enable to create a connection to get data.
Token : <token><version>1</version><data>xxxx</data></token>
AFAS Snapshot :
I'm not familiar with AFAS myself, but found the following by googling a bit. It looks like the Authorization header is created by base64 encoding the appToken (I assume this is the one you got already) like:
$token = '<token><version>1</version><data>49D9BAF55B80B93BA6DBE4EF64F5728DADB4215A35BBF9D444E09CAB5F5C3913</data></token>';
And then add it as the Authorization header on a request, like:
Authorization: AfasToken base64_encode($token)
There's no built-in base64 encoder in QlikView / Qlik Sense script afak so the encoding needs to be done externally
Here's some example code that I found:
Hope this helps