Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
How to set up google oauth only using ajax and jquery

I am trying to use google oauth using ajax and jquery. I have no errors but when I click on login button, page refresh to current page. This makes me think, issue is with ajax. maybe I am missing a flag or field.

I want to go to google login page. and on success, i want to get user first name.

    <script type="text/javascript">
        $(document).ready(function () {
            $('.LoginGoogleC').click(function () {
                alert('start');
                $.ajax({
                    type: 'POST',
                    url: "https://accounts.google.com/o/oauth2/token",
                    contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                    crossDomain: true,
                    cache: true,
                    dataType: 'json',
                    data: {
                        client_id: '0000000-18911.apps.googleusercontent.com',
                        client_secret: 'fff-eee-fff',
                        redirect_uri: 'https://localhost:44329/LoginAPI.aspx',
                        grant_type: 'authorization_code'
                    },
                    success: function (data) {
                        alert('success' + data);
                    },
                    error: function (e) {
                        alert('error' + data);
                    }
                });
                alert('done');
            }); 
        });
    </script>

I also tried using only jquery but still same thing. page refresh but no google oauth page

        var clientID = '0000000-18911.apps.googleusercontent.com';
            var redirectURL = 'https://localhost:44329/LoginAPI.aspx';
            window.location.href = 'https//accounts.google.com/o/oauth2/v2/auth?' +
                'scope=openid%20email' +
                '&response_type=token' +
                '&redirect_url=' + redirectURL +
                '&client_id=' + clientID;

button - html

    <asp:button ID="LoginGoogleB" CssClass="LoginGoogleC btn btn-lg center-block" runat="server" 
    Text="Login With Google" />
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda