准备工作是你要在官网创建应用,获取它们给你的id
Google 登录
1,在google开发者后台创建应用
2,通过后台进行申请获取id
最近在试着用google登录,当然这只是简单的登录,直接用的它的官方文档给出的代码。上线以后才能实现,还要用https链接才行,不然会认为你的链接不安全。有可能会被阻止。
1.先引入官方的js文件
<meta name="google-signin-client_id" content="Client ID">
<script src="https://apis.google.com/js/platform.js" async defer></script>
2.再放入代码
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
<script>
function onSignIn(googleUser) {
// Useful data for your client-side scripts:
var profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId()); // Don't send this directly to your server!
console.log('Full Name: ' + profile.getName());
console