罕见的例外 "android.accounts.AuthenticatorException: ServiceDisabled" - 这是什么意思?

Rare exception "android.accounts.AuthenticatorException: ServiceDisabled" - what does this means?

编辑 3(7 月)

问题又来了!

android.accounts.AuthenticatorException: ServiceDisabled

所以我的电子邮件应用程序无法再连接到 GMail。

有人可以帮忙吗?

谢谢

编辑 2(3 月 7 日)

也许为 Android 创建一个 "ID clients OAuth 2.0" 可以解决这个问题.. 此 ID 必须在此页面上创建 https://console.developers.google.com/apis/credentials

调查正在进行中..


编辑

我觉得跟这个有关https://wordpress.org/support/topic/be-careful-everybody-who-is-using-oauth-2-0-to-access-gmail-google-gsuite-apis/

我应该怎么做才能让我的应用程序获准使用 oauth2:https://mail.google.com/ scope


受影响用户的反馈 - 这是这个问题的原因吗?

他创建了许多 Google 帐户(做一些测试)。 这是否与创建的 Google 个帐户数量过多有关,这些帐户 'linked' 到他的初始电子邮件地址(使用相同的初始帐户进行恢复)? 错误假设


我的电子邮件应用程序正在使用 AccountManager 访问 GMail(使用 OAuthToken )并且它工作正常(自 2102 年以来),除了我现在有一个特殊的异常 只发生在特定的 Google 账户

这似乎是一个很新的行为

这里的错误是:

W/System.err: android.accounts.AuthenticatorException: ServiceDisabled
W/System.err:     at android.accounts.AccountManager.convertErrorToException(AccountManager.java:2507)
W/System.err:     at android.accounts.AccountManager.-wrap0(Unknown Source:0)
W/System.err:     at android.accounts.AccountManager$AmsTask$Response.onError(AccountManager.java:2350)
W/System.err:     at android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69)
W/System.err:     at android.os.Binder.execTransact(Binder.java:697)

问题:

  1. "android.accounts.AuthenticatorException: ServiceDisabled" 错误究竟是什么意思?
  2. 为什么这只发生在这个 google 帐户上? (可能还有其他一些,但根据用户反馈,这似乎很少见)。我应该检查此帐户的某些 Android Google 帐户设置吗?哪些?

因此,相同的代码适用于我在 Phone 上测试的大约 10 个帐户,但对于这个非常具体的 Google 帐户却失败了!为什么?

仅供参考,我在这里开了一个问题:https://issuetracker.google.com/issues/127454208

注:

根据此帐户的所有者的说法,该应用程序之前可以运行,然后突然停止运行:我正在调查它何时发生以及他是否可以给我一些提示,说明他当时可能采取的一些行动时间.

预先感谢您的帮助。


我收集的一些信息:

我设法对此进行了一些调试,发现堆栈跟踪在 cpp 中走得更远:

jboolean res = env->CallBooleanMethod(mObject, gBinderOffsets.mExecTransact,
        code, (int32_t)&data, (int32_t)reply, flags);

https://android.googlesource.com/platform/frameworks/base/+/f76a50c/core/jni/android_util_Binder.cpp

我发现 "res = onTransact(code, data, reply, flags);"(即来自 AIDL 的 android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69) 是用

调用的
code = 2 (probably android.accounts.AccountManager.VISIBILITY_USER_MANAGED_VISIBLE = 2)
data : a Parcel Object 
reply : another Parcel Object 
flags = 17

这看起来不错,并且适用于所有其他 Google 帐户!

我也查到AccountManager.convertErrorToException中的错误码 是代码 ERROR_CODE_INVALID_RESPONSE

问题理解并解决了!

自 2019 年 1 月以来,some OAuth2 scopes are restricted
此外,Additional Requirements for Specific API Scopes 页面声明:

Enforcement of the requirements in this section will begin on January 15, 2019 when all new applications must undergo a new application review process before accessing certain API scopes. Applications submitted for verification before January 15, 2019 will be given a grace period to come into compliance, and must submit for re-review no later than February 15, 2019. To learn more about these new requirements, read our blog post, Elevating user trust in our API ecosystem, and the OAuth Application Verification FAQ.

为了使您的 Android 应用符合此要求,您必须为 Android 创建一个新的 "ID clients OAuth 2.0"。

必须在此页面上创建此 ID https://console.developers.google.com/apis/credentials

奇怪的是,所有这些似乎都与 G Suite 和 Google API 相关,而不是 Android SDK。
这可能是因为 Android SDK 的 OAuth 部分在幕后使用了 Google API,更准确地说,AccountManager#getAuthToken 方法确实使用了它。