-1

I want to integrating Google Sign-In into your google script, somebody help me how do i do ? step by step. I had file html home! tks homie.

Naoa Lee
  • 135
  • 2
  • 19
  • Check the official [documentation](https://developers.google.com/identity/sign-in/web/sign-in) how to integrate Google Sign-in into your web app. It describes how to complete a basic Google Sign-In integration with step by step procedure. – Jessica Rodriguez Jun 06 '19 at 14:25

1 Answers1

0

To integrate Google Sign-in to your web you can follow the process mentioned in the bellow article:

https://developers.google.com/identity/sign-in/web/sign-in

Also If you need additional information about how to integrate HTML in your code you can read the following link:

https://developers.google.com/apps-script/guides/html/

Finally, here is an implementation example about how to do it (only clientID missing):

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="google-signin-client_id" content="#clientId">
    <title>Oauth2 web</title>

    <!-- Google library -->
    <script src="https://apis.google.com/js/platform.js" async defer></script>

    <!-- Jquery library to print the information easier -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>

    <!-- Bootstrap library for the button style-->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div id="profileinfo">
</div>
<div class="g-signin2" data-onsuccess="onSignIn"></div>

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

              $("#profileinfo").append("<h2>Sup " + profile.getName() + ", welcome home my friend</h2>");
              $("#profileinfo").append("<img style='width:250px;height:250px' src='" + profile.getImageUrl() + "'><br><br>");
              $("#profileinfo").append("<p>Your email is: " + profile.getEmail() + "</p>");

            }
        </script>

<button type="button" class="btn btn-danger" onclick="signOut();">Sign out</button>

<script>
            function signOut() {
               var auth2 = gapi.auth2.getAuthInstance();
               auth2.signOut().then(function () {
                 console.log('User signed out.');
               $("#profileinfo").empty();
               $("#profileinfo").append("<h2>Goodbye old friend</h2>");
               });
            }
        </script>
</body>
</html>
Andres Duarte
  • 3,166
  • 1
  • 7
  • 14
  • Thank you for answering my question. I create cIientID and put meta name but it not run result is " Error: redirect_uri_mismatch ". You can help me ? – Naoa Lee Jun 28 '19 at 06:47
  • Ask another question with the steps you made, the error message, the environment where you're running it, etc. I'll watch it. – Andres Duarte Jun 28 '19 at 07:18
  • Thanks you ! this is link of new my question https://stackoverflow.com/questions/56803054/get-gmail-address-using-google-apps-script-error-redirect-uri-mismatch . Please help me ! – Naoa Lee Jun 28 '19 at 08:07
  • Sorry, the first time i didn't see the app-script tag so i thought it was on a normal server. I'm on it. – Andres Duarte Jun 28 '19 at 11:21