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

168
Views
Cómo configurar google oauth solo usando ajax y jquery

Estoy tratando de usar google oauth usando ajax y jquery. No tengo errores, pero cuando hago clic en el botón de inicio de sesión, la página se actualiza a la página actual. Esto me hace pensar, el problema es con ajax. tal vez me falta una bandera o un campo.

Quiero ir a la página de inicio de sesión de Google. y en caso de éxito, quiero obtener el nombre de usuario.

 <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>

También intenté usar solo jquery pero sigue siendo lo mismo. actualización de página pero sin página de autenticación de Google

 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;

botón - 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
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!