[英]Add Google Sign-In to Your Web using AngularJS
我已經嘗試了一個演示及其工作原理,但是當我嘗試角度演示時,效果並不理想。 問題是一個函數,它不起作用 。
登錄按鈕
<div class="g-signin2" data-onsuccess="onSignIn()" data-theme="dark"></div>
添加依賴關系並創建clientID
<meta name="google-signin-scope" content="profile email">
<meta name="google-signin-client_id" content="******644722-rv6i1sh8437nc82o8egufkui0424k1qg.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
函數調用
$scope.onSignIn=function(googleUser){
var profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId());
console.log('Full Name: ' + profile.getName());
console.log('Given Name: ' + profile.getGivenName());
console.log('Family Name: ' + profile.getFamilyName());
console.log("Image URL: " + profile.getImageUrl());
console.log("Email: " + profile.getEmail());
var id_token = googleUser.getAuthResponse().id_token;
console.log("ID Token: " + id_token);
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.