Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

REST Connector for Facebook

Hi,

I tried to use REST Connector in Qlik Sense to get data from my Facebook profile.I followed this steps Connecting to Facebook using Qlik REST Connector - YouTube but when I tried to Create connection, this error showed up:

error.PNG

Does anyone know how to solve this problem?

5 Replies
Anonymous
Not applicable
Author

i have the same issue

Anonymous
Not applicable
Author

Hi Diana,

I got the same error when i try to connect.

Have you got any solution?

Please let me know.

BalaBhaskar_Qlik
Master
Master

Try like this:

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). I then followed the same process as above, and used WITH CONNECTION to alter the LIB settings and pointed the URL to the entry-points for Google APIs. Here's a small example script for Sense:

  1. IF vTokenExpires <= now() THEN 
  2.   LET vRequestBody =''; 
  3.   LET vRequestBody = vRequestBody & 'grant_type=refresh_token'; 
  4.   LET vRequestBody = vRequestBody & '&client_id=' & '$(vClient_id)'; 
  5.   LET vRequestBody = vRequestBody & '&client_secret=' & '$(vClient_secret)'; 
  6.   LET vRequestBody = vRequestBody & '&refresh_token=' & '$(vRefresh_token)'; 
  7.   LIB CONNECT TO 'Google Authorization'; 
  8.   access_token: 
  9.   SQL SELECT 
  10.   "access_token", 
  11.   "token_type", 
  12.   "expires_in" 
  13.   FROM JSON (wrap on) "root" 
  14.     WITH CONNECTION ( 
  15.     URL "https://www.googleapis.com/oauth2/v4/token", 
  16.     HTTPHEADER "Content-Type" "application/x-www-form-urlencoded", 
  17.   BODY "$(vRequestBody)" 
  18.   ); 
  19.   LET vExpiresIn = peek('expires_in',0,'access_token'); 
  20.   LET vAccessToken = peek('access_token',0,'access_token'); 
  21.   LET vTokenExpires = timestamp(now() + $(vExpiresIn)/86400); 
  22. ENDIF   

Refer this:

REST CONNECTOR locate the Authorization token

petter
Partner - Champion III
Partner - Champion III

The recipe you gave is for Google and not Facebook. The process is not similar as you can't get a USER ACCESS TOKEN in Facebook via an API-call. You *have* to have a user dialog interaction to retrieve it.

petter
Partner - Champion III
Partner - Champion III

While in the "facebook for developers" / Graph API Explorer page and you press the drop-down "Get Token" - make sure that you really select the "Get User Access Token" as it is different from the "Get App Token" which can't be used.

2018-08-01 09_33_14-(11) Connecting to Facebook using Qlik REST Connector - YouTube.png

Notice that the generated Access Token (User Access Token) is very long and much longer than the App Token.

This has to be used as a query parameter with the name access_token in the REST Connector dialog box.

NOTICE: The User Access Token expires after two hours - after that you will have to get a new one. Alternatively you can extend the User Access Token to have a two months/60 days expiration in the "Graph API Explorer".