android - Android - Google OAuth 2 - 使用不同验证码的两次响应
问题描述
我在 Android 9 及更低版本上遇到了 Oauth Google 问题。
设置:
我开发了一个应用程序:
- 本机脚本 7
- 角 11
- nativescript-oauth2:3.0.3 插件
问题 :
我不确定问题出自 nativescript-oauth2 插件,可能是我的 android 应用程序配置或 Google Frame。
我使用 Facebook 和 Google 提供商开发了 OAuth 登录。对于 Facebook,没问题。
Facebook 使用网络视图浏览器,而 Google 使用本地视图浏览器。
对于谷歌,见下文:
- 在带有 android 10 的模拟器上:一切正常
- 在带有 android 8 或 9 的模拟器上:
- 它打开浏览器以使用 Google 登录 => 我选择我的帐户 => 重定向到带有等待消息的 Google 页面 => 它永远不会重定向到我的应用程序,过了一会儿,它重定向到
www.google.com
- 它打开浏览器以使用 Google 登录 => 我选择我的帐户 => 重定向到带有等待消息的 Google 页面 => 它永远不会重定向到我的应用程序,过了一会儿,它重定向到
- 在具有多个 Google 帐户的真实设备(android 9)上,我有 2 种行为:
- 首先:它打开浏览器以使用 Google 登录 => 我选择我的帐户 => 使用“等待”消息重定向到 Google 页面 => 使用
The login operation was canceled
错误消息重定向到我的应用程序 - 第二:它打开浏览器以使用 Google 登录 =>我稍等片刻(例如 1 分钟) => 我选择我的帐户 => 重定向到 Google 页面
Waiting message
=> 重定向到我的应用程序 => 它工作正常
- 首先:它打开浏览器以使用 Google 登录 => 我选择我的帐户 => 使用“等待”消息重定向到 Google 页面 => 使用
- 在只有一个帐户 Google 的其他真实设备上(在 android 设置中),没关系
更多细节: 我调试了应用程序和 nativescript-oauth2 插件。我看到带有等待消息的谷歌框架(在选择谷歌帐户后)向 Android 发送了 2 个事件,其中“代码”参数的值不同。当然,第一个代码已过期/撤销,Google 返回错误。
在 OAuth Google 文档中,这是第 4 步,它使用 2 个代码发送 2 个响应。
我的问题
为什么 Google Frame 浏览器会向我发送 2 个事件?
代码 :
这是我的 AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="__PACKAGE__"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.tns.NativeScriptActivity"
android:label="@string/title_activity_kimera"
android:launchMode="singleTask"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
android:theme="@style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Custom URL Schemes -->
<data android:path="/auth"
android:scheme="com.googleusercontent.apps.xxxxxxxx-yyyyyyyyyyyyyyyyyy"/>
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="xxxxxxxxxxxxxxxxx" />
</application>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="__APILEVEL__"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>
解决方案
推荐阅读
- javascript - 以高质量将图表导出为 pdf。模糊变焦
- angular - 单击页面上的任意位置后,数据显示在 HTML 上
- transform - 任何人都在转换设计器中使用过“打印到 PDF”选项???(底线)
- laravel - Laravel更新关系表不起作用
- android - Charles Proxy 无法在 Android 模拟器上运行:未提供 SNI;请修复你的客户
- dynamics-crm - 是否有关于在 EntityMetadata 中创建实体记录的可能性的任何信息?
- r - 访问R中嵌套列表中具有特定名称的所有列
- kubernetes - 如何使用 kubectl 扩展关于 kubernetes 的守护进程集
- snowflake-cloud-data-platform - 不稳定的“延迟”CTE 评估?
- android - 具有渐变颜色的矢量可绘制不低于 API 24