Meta API with User Token Returns Empty Response
Here are the steps I took to get access_token
// Init FB SDK const loadSdk = () => { window.fbAsyncInit = function () { window.FB.init({ appId: "218446344509498", cookie: true, xfbml: true, version: "v19.0", }); }; if (!document.getElementById("facebook-jssdk")) { const js = document.createElement("script"); js.id = "facebook-jssdk"; js.src = `https://connect.facebook.net/en_US/sdk.js`; document.body.appendChild(js); } }; loadSdk();
Then I opened the popup that I need for whatsapp embedded sign up
window.FB.login((response) => { if (response.authResponse) { const code = response?.authResponse?.code; console.log(code) } }, { config_id: <config-id>, // configuration ID goes here response_type: "code", override_default_response_type: true, scope: 'business_management, whatsapp_business_management, whatsapp_business_messaging', })
When I code the code I retrieved my access_token on the server side using the following API
https://graph.facebook.com/v20.0/oauth/access_token?client_id=<client-id>&client_secret=<client-secret&code=<code-i-previously-retrived>
This returns me an access token that seems to be working with Meta APIs /me, //owned_whatsapp_business_accounts But it returns empty arrays or objects.
When I do the same thing from Meta explorer (select permissions, generate token, copy that token and use, it works)
I have been trying to solve this since many days and not sure where I am doing the mistake.
I want to generate token with correct permissions (it looks like I am doing it because authentication popup also mentions the permissions I requested), and want to able to fetch information from it not empty array