angular - Google+ API 未触发 onSignIn 调用
问题描述
我有一个 Angular 项目,我正在尝试创建一个按钮,允许用户登录到他们的 Google+ 帐户,以便获取用户名、电子邮件和个人资料图片等信息。我在这里遵循了本教程:
我在 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。在这里阅读更多
推荐阅读
- pivot - DolphinDB 数据透视表
- react-native - 通过 Redux 访问 SectionList 的数据
- php - 如何从数据库中获取随机元组?
- c++ - 将 Boost.Coroutine 与 Boost.ASIO 一起使用会导致断言
- ruby-on-rails - 在 `has_many` 关联上添加 `or`
- parsing - 如何在 Haskell 中使用解析器来查找字符串中某些子字符串的位置?
- ruby-on-rails - Rspec测试调用方法发送再确认指令
- php - 语法错误或访问冲突:1064,LEFT JOIN 条件上的语法错误
- unity3d - 如何修复“无法正确加载程序集 nunit.framework 的调试符号。Mono 运行时不支持完整的 pdb?”
- java - 检查数组中的素数并返回素数之和