Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
niclaz79
Partner - Creator III
Partner - Creator III

Issue with refreshing Google Business authorization key

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 get the following error message:

HTTP protocol error 400 (Bad Request): { "error": "invalid_grant", "error_description": "Bad Request" }

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.

0 Replies