Hi, I'm trying to run the following script in order to refresh my authorization key for a Google Business account. I can use the playground to obtain it manually, but obviously I need to be able to automate it in Qlik Sense.
I have changed the client id, client secret and refresh token secrets for this post, but there are real values there in the actual code
SET vClient_id = 'client id'; SET vClient_secret = 'client secret';
SET vRefresh_token = 'refresh token';
LET vRequestBody =''; LET vRequestBody = vRequestBody & 'grant_type=refresh_token'; LET vRequestBody = vRequestBody & '&client_id=' & '$(vClient_id)'; LET vRequestBody = vRequestBody & '&client_secret=' & '$(vClient_secret)'; LET vRequestBody = vRequestBody & '&refresh_token=' & '$(vRefresh_token)';
LIB CONNECT TO 'Google Authorization';
access_token: SQL SELECT "access_token", "token_type", "expires_in" FROM JSON (wrap on) "root" WITH CONNECTION ( URL "https://accounts.google.com/o/oauth2/token", HTTPHEADER "Content-Type" "application/x-www-form-urlencoded", BODY "$(vRequestBody)" ) ;
LET vAccessToken = peek('access_token',0,'access_token');
I feel there could be a setting on the Google Business side that I need to make, but I cannot find any resources that tells me what that is. And as I said, it works fine in playground to get a new authorization code.
Re: Issue with authorization key for Google Business
"Invalid Grant" seems to be a very generic error but mostly its related to tokens and access permissions. It can be as simple as the user blocking the access or that the tokens themselves are old. There is a great post about this issue here: