0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Google でログイン (Javascript API)

Last updated at Posted at 2023-08-15

こちらと同じことを、Javascript API で実装しました。
Google でログイン を設定

こちらのページを参考にしました。
【Google】ワンタップログイン

Web ページ

index.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>
Login Test
</title>
</head>
<body>
<script src="https://accounts.google.com/gsi/client" async defer></script>
<script src="login.js"></script>
<div id="buttonDiv"></div>
<hr />
<div id="outarea_aa">outarea_aa</div>
<div id="outarea_bb">outarea_bb</div>
<div id="outarea_cc">outarea_cc</div>
<div id="outarea_dd">outarea_dd</div>
<div id="outarea_ee">outarea_ee</div>
<div id="outarea_ff">outarea_ff</div>
<div id="outarea_gg">outarea_gg</div>
<div id="outarea_hh">outarea_hh</div>
<p>Aug/15/2023 PM 13:59</p>
</body>
</html>
login.js
// -----------------------------------------------------------------------
function handleCredentialResponse(response) {
	  console.log("Encoded JWT ID token: " + response.credential);
	}

// -----------------------------------------------------------------------
window.onload = function ()
{
	document.querySelector("#outarea_aa").innerHTML
		= "*** login.js *** start ***"

	google.accounts.id.initialize({
	client_id: "371868132900-eg26ng307au*******.apps.googleusercontent.com",
	    callback: handleCredentialResponse
	  });
	  google.accounts.id.renderButton(
	    document.getElementById("buttonDiv"),
	    { theme: "outline", size: "large" }  // customization attributes
	  );
	  google.accounts.id.prompt(); // also display the One Tap dialog


	document.querySelector("#outarea_hh").innerHTML
		= "*** login.js PM 14:16 *** end ***"

}
// -----------------------------------------------------------------------

ブラウザーでアクセス

image.png

関連ページ

Sign In With Google JavaScript API

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?