Я хочу интегрировать Google Sign-In в ваш скрипт Google, кто-нибудь, помогите мне, как мне это сделать? шаг за шагом. У меня был файл html дома! спс братан.





Чтобы интегрировать Google Sign-in в свой веб-сайт, вы можете выполнить процесс, описанный в следующей статье:
https://developers.google.com/identity/sign-in/web/sign-in
Также, если вам нужна дополнительная информация о том, как интегрировать HTML в ваш код, вы можете прочитать следующую ссылку:
https://developers.google.com/apps-script/guides/html/
Наконец, вот пример реализации о том, как это сделать (отсутствует только clientID):
<!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.info('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.info('Name: ' + profile.getName());
console.info('Image URL: ' + profile.getImageUrl());
console.info('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.info('User signed out.');
$("#profileinfo").empty();
$("#profileinfo").append("<h2>Goodbye old friend</h2>");
});
}
</script>
</body>
</html>
Спасибо, что ответили на мой вопрос. Я создаю cIientID и ввожу метаимя, но результат не запускается: «Ошибка: redirect_uri_mismatch». Вы можете мне помочь ?
Задайте другой вопрос с шагами, которые вы сделали, сообщением об ошибке, средой, в которой вы его запускаете, и т. д. Я посмотрю.
Спасибо вам ! это ссылка на новый мой вопрос stackoverflow.com/questions/56803054/…. Пожалуйста помогите !
Извините, в первый раз я не увидел тег app-script, поэтому подумал, что это на обычном сервере. Я готов.
Ознакомьтесь с официальным документация, как интегрировать Google Sign-in в ваше веб-приложение. В нем описывается, как выполнить базовую интеграцию Google Sign-In с пошаговой процедурой.