Google+ API 未触发 onSignIn 调用
Google+ API not firing onSignIn call
我有一个 Angular 项目,我正在尝试创建一个按钮,允许用户登录他们的 Google+ 帐户以获取用户名、电子邮件和个人资料图片等信息.
我已遵循本教程 here:
我在 index.html 页面中添加了以下内容:
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="YOUR_CLIENT_ID.apps.googleusercontent.com">
然后我在 app.component.html
中添加了以下内容
<div class="g-signin2" data-onsuccess="onSignIn"></div>
然后我终于在我的app.component.ts中添加了这个回调函数:
onSignIn(googleUser) {
let 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.
}
我的问题是 onSignIn 回调函数由于某种原因从未被调用。关于为什么会这样的任何想法?如果您有任何问题,我会及时回复。
Google+ API 将于 2019 年 3 月 7 日关闭,因此我决定不集成此 API。阅读更多 here
我有一个 Angular 项目,我正在尝试创建一个按钮,允许用户登录他们的 Google+ 帐户以获取用户名、电子邮件和个人资料图片等信息. 我已遵循本教程 here:
我在 index.html 页面中添加了以下内容:
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="YOUR_CLIENT_ID.apps.googleusercontent.com">
然后我在 app.component.html
中添加了以下内容<div class="g-signin2" data-onsuccess="onSignIn"></div>
然后我终于在我的app.component.ts中添加了这个回调函数:
onSignIn(googleUser) {
let 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.
}
我的问题是 onSignIn 回调函数由于某种原因从未被调用。关于为什么会这样的任何想法?如果您有任何问题,我会及时回复。
Google+ API 将于 2019 年 3 月 7 日关闭,因此我决定不集成此 API。阅读更多 here