Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda