-1

I want to login with google plus using javascript,below is my code

index.html

Here i placed all scripts,html code

<html>
       
      <title>Login With google plus</title>
      <meta name="google-signin-client_id" 
      content="aaaaaaaaaaa.apps.googleusercontent.com ">

     <script src="jquery.min.js"></script>
     <script src="https://apis.google.com/js/client:platform.js? 
     onload=renderButton" async defer></script>

       <script>
          function onSuccess(googleUser) {
          var profile = googleUser.getBasicProfile();
          gapi.client.load('plus', 'v1', function () {
          var request = gapi.client.plus.people.get({
         'userId': 'me'
          });
   
        request.execute(function (resp) {
        var profileHTML = '<div class="profile"><div class="head">Welcome 
        '+resp.name.givenName+'! <a href="javascript:void(0);" 
        onclick="signOut();">Sign out</a></div>';
        profileHTML += '<img src="'+resp.image.url+'"/><div 
        class="proDetails"><p>'+resp.displayName+'</p> 
        <p>'+resp.emails[0].value+'</p><p>'+resp.gender+'</p> 
        <p>'+resp.id+'</p><p><a href="'+resp.url+'">View Google+ Profile</a> 
        </p></div></div>';
        $('.userContent').html(profileHTML);
        $('#gSignIn').slideUp('slow');
        });
      });
     }
     function onFailure(error) {
        alert(error);
         }
      function renderButton() {
             gapi.signin2.render('gSignIn', {
             'scope': 'profile email',
             'width': 240,
             'height': 50,
             'longtitle': true,
             'theme': 'dark',
             'onsuccess': onSuccess,
             'onfailure': onFailure
        });
      }
     function signOut() {
         var auth2 = gapi.auth2.getAuthInstance();
         auth2.signOut().then(function () {
         $('.userContent').html('');
         $('#gSignIn').slideDown('slow');
     });
   }
  </script>

 <div id="gSignIn"></div>

 <div class="userContent"></div>

</html>

but when i want to login this error will show.

  1. That’s an error.

Error: invalid_client

The OAuth client was not found.

I can't get this error, please help me to solve this error.

5
  • 3
    Make sure that at Google console, project is published, project's return url is valid, etc. Issue is related to config.
    – user2575725
    Commented May 10, 2018 at 8:46
  • no i am not give any url in authorized redirect url ,i am give localhost in Authorized JavaScript origins
    – dipti
    Commented May 10, 2018 at 8:55
  • url needs to be absolute including ports
    – user2575725
    Commented May 10, 2018 at 9:03
  • it also return same error ,after giving redirect url
    – dipti
    Commented May 10, 2018 at 9:23
  • link
    – Ramlal S
    Commented May 10, 2018 at 10:27

1 Answer 1

0

You have to register your application with google console to be able to use the OAuth, You will have to specify the return url after OAuth is granted by the client

1
  • it will return an error as Error: invalid_client The OAuth client was not found.
    – dipti
    Commented May 10, 2018 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.