Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Fb login button causes infinity loops in FB built-in browser

I'm using FB login button to provide 1-click login on my website. It is working fine on almost all of the browsers. However it does not work on FB built-in browser. Here is my code:

HTML:

<script async defer crossorigin="anonymous" 
        src="https://connect.facebook.net/bg_BG/sdk.js#xfbml=1&version=v12.0&appId={appID}&autoLogAppEvents=1" 
        nonce="{nonce}"></script>
<div class="fb-login-button" 
     data-width="300" 
     data-size="large" 
     data-button-type="continue_with" 
     data-layout="default" 
     data-auto-logout-link="false" 
     data-use-continue-as="false" 
     scope="public_profile,email" 
     onlogin="checkLoginState()">
</div>

JS:

function loginCallbackOnButtonClick(response) {
    let dataObject, authResponse;        

    if (!response || response.status != "connected" || !response.authResponse) {
        return;
    }

    authResponse = response.authResponse;

    dataObject = {            
        accessToken: authResponse.accessToken,
        signedRequest: authResponse.signedRequest,
        fbUserID: authResponse.userID,
        urlReferrer: urlReferrerInput.value
    };

    // send data to back-end to verify
    $.ajax({
        url: '/Account/FbLogin',
        type: 'post',
        data: dataObject,
        success: function (response) {
            // handle successful verification                
        }
    });
}

window.fbAsyncInit = function () {
    FB.init({
        appId: '{appID}',
        cookie: true,
        xfbml: true,
        version: 'v12.0'
    });        
};

(function (d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) { return; }
    js = d.createElement(s); js.id = id;
    js.src = "https://connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

window.checkLoginState = function () {        
    FB.getLoginStatus(loginCallbackOnButtonClick);
};

Again, this code work very well on almost all of the browsers, but not in FB built-in browser, where on button click our login page (where the button is placed) reloads and nothing happens.

I tried the following: when user comes on our login page and he is using FB built-in browser, to call

FB.login(loginCallbackOnButtonClick, {
                scope: 'public_profile,email',
                enable_profile_selector: true,
                auth_type: 'rerequest',
                return_scopes: true
            });

I tried to debug somehow using logger here and there in the code and display in textarea the logs, what code is executed and it seems that loginCallbackOnButtonClick is never called as a callback.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!