oauth-2.0 - 在 Ionic 4 上使用 Google 的 Oauth2 进程卡在“请稍候”
问题描述
我有一个从 github.com/ionicthemes/ionic-google-login 粘贴的教程 Ionic 4 应用程序我有以下代码被调用:
this.googlePlus.login({
'scopes': '', // optional - space-separated list of scopes, If not included or empty, defaults to `profile` and `email`.
'webClientId': environment.googleWebClientId, // optional - clientId of your Web application from Credentials settings of your project - On Android, this MUST be included to get an idToken. On iOS, it is not required.
'offline': true, // Optional, but requires the webClientId - if set to true the plugin will also return a serverAuthCode, which can be used to grant offline access to a non-Google server
}).then(user => {
console.log('+++ user is:', user);
}, err => {
console.log("+++ google login error:", err);
})
既不成功,也不打印错误消息。我一直在等待 Google 的回复。
我这样做了:keytool -exportcert -keystore path-to-debug-or-production-keystore -list -v
并在 console.developers.google.com 上添加了 sha1 指纹。包名匹配(com.tgm_ionic),我选择了 oauth2 android flow。
额外信息:这曾经在浏览器平台上工作,但在 android 模拟器上会失败,错误 10,即“无效观众”。所以我创建了新的凭据以从浏览器平台移动到 android 平台(仍然是 oauth2),现在我遇到了这个问题。这里的目标是能够在 android 上登录,而不是在浏览器中。
解决方案
验证您的 webClientId 是否正确。您可以在 Google API 控制台中引用它,然后查看凭据并检查您的 OAuth 2.0 客户端 ID。当需要 Web 客户端 ID 时,通常使用这些混合应用程序的人会使用 android 密钥。
推荐阅读
- amazon-web-services - 使用 Lambda 函数通过 Python 读取某个 Cloudwatch 警报状态及其指标
- ssh - ssh 向远程发送命令时如何获取 ~/.bashrc
- python - 如何将熊猫数据框写入现有的 xlsx 文件?
- macos - 开发板 NodeMCU 1.0 (ESP-12E Module) 编译时出错(读取 10 次)
- javascript - Redux-persist for reactJS 给出错误:Firefox 78.0.2 中的 noop 存储
- javascript - Angular html中的Highcharts
- vue.js - 使用 yarn install 时 Nuxt/Vuetify 的原色是黑白(附截图)
- python - 从字典键及其值生成元组
- c# - Add-Migration MyModel 提供空的 Up() Down() 方法
- vue.js - Vue beforeEach() 没有重定向到所需的页面