I need to get authenticated for Instagram API. I have a business profile. And I'm trying to authenticate via FB login via the JS SDK:

  <p id="profile"></p>   <script>     function checkLoginState() {       FB.getLoginStatus(function(response) {         statusChangeCallback(response);       });     }     window.fbAsyncInit = () => {       FB.init({         appId: 'xxxxxxxxxxxxxx',         cookie: true,          xfbml: true,         version: 'v19.0'       });       FB.login((response) => {         if (response.authResponse) {              console.log('Welcome!  Fetching your information.... ');              FB.api('/me', {fields: 'name, email'}, (response) => {               const msg = `Howdy ${response.name}. Your email address: ${response.email}`;               document.getElementById("profile").innerHTML = msg;              });         } else {            console.log('User cancelled login or did not fully authorize.'); }       });       FB.getLoginStatus((response) => {         if (response.status === 'connected') {           console.log(response.authResponse);           alert(`response.authResponse: ${response.authResponse}`);         }       });     }; </script> <!-- The JS SDK Login Button --> <fb:login-button scope="public_profile,email" onlogin="checkLoginState();"> </fb:login-button> <div id="status"> </div> <script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script> 

I click the button, get redirected at FB, enter login/pass in the dialog window, enter 2FA code. And then it'll ALWAYS get stuck on this dialog, on the half-way:

with this url (modified):

What's going on here?

Tag:facebook, facebook-graph-api, facebook-javascript-sdk

2 comments.

  1. Khoa Nguyễn
    FB.login((response) => { if (response.authResponse) { console.log('Welcome! Fetching your information....'); FB.api('/me', { fields: 'name, email' }, (response) => { const msg = `Howdy ${response.name}. Your email address: ${response.email}`; document.getElementById("profile").innerHTML = msg; }); } else { console.log('User cancelled login or did not fully authorize.'); } }, { scope: "pages_show_list,pages_read_engagement" }; I hope I can help you.
    1. Community

      As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Add a new comment.