Home Using Google OAuth Login to proceed in js
Reply: 0

Using Google OAuth Login to proceed in js

user1479 Published in July 22, 2018, 8:05 pm

I have a problem with the Google Sign in. Im using https://developers.google.com/identity/sign-in/web/sign-in to get a google sign in, but I dont know how to display the user information in html nor how to proceed with it so it can be used as credentials for Wordpress Login. The login form is a custom design in HTML, the connection to wp-login.php works, but I want to integrate OAuth for google, etc. Please help, thanks.

<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="xxx.apps.googleusercontent.com">

<div class="g-signin2" data-onsuccess="onSignIn"></div>

<a href="#" onclick="signOut();">Sign out</a>

<p id="demo"></p>

  function signOut() {
    var auth2 = gapi.auth2.getAuthInstance();
    auth2.signOut().then(function () {
      console.log('User signed out.');

function onSignIn(googleUser) {
  var profile = googleUser.getBasicProfile();
  console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
  console.log('Name: ' + profile.getName());
  console.log('Image URL: ' + profile.getImageUrl());
  console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
  document.getElementById("demo").innerHTML = onSignIn(profile.getName);

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301291 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO