- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试使用 AccountManager.confirmCredentials我的应用程序中的用户验证方法。我是这样使用它的:
AccountManager am = AccountManager.get(ctx);
am.confirmCredentials(account, null, ctx, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> amf) {
try {
Bundle b = amf.getResult();
boolean r = b.getBoolean(AccountManager.KEY_BOOLEAN_RESULT);
vc.onValidateResult(r);
return;
} catch (OperationCanceledException ignore) {
} catch (AuthenticatorException ignore) {
} catch (IOException ignore) {
}
vc.onValidateResult(false);
}
}, null);
但发现自 Android 5 以来其实现存在差距。用户可以清除 Google 授权表单中建议的帐户名称并使用他/她自己的帐户名称。结果将是肯定的,并且无法验证请求的帐户名是否用于确认,因为获取的包只有时间戳和结果 bool 值。换句话说,该 bundle 没有 KEY_ACCOUNT_NAME
字段,但是根据它应该有的引用。
有人知道如何解决此漏洞吗?
最佳答案
根据文档:
If no activity or password was specified, the returned Bundle contains KEY_INTENT with the Intent needed to launch the password prompt. Also the returning Bundle may contain KEY_LAST_AUTHENTICATED_TIME indicating the last time the credential was validated/created.
如果您的结果不包含帐户名称,则一定是由于上述情况。您应该检查 Intent 是否包含 KEY_INTENT
,如果包含则启动该 Intent 进行验证。
关于android - AccountManager.confirmCredentials 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57288845/
我正在尝试使用 AccountManager.confirmCredentials我的应用程序中的用户验证方法。我是这样使用它的: AccountManager am = AccountMan
我不明白方法 confirmCredentials 是如何工作的。我从未在 Android UI 中看到任何选项,例如“确认凭据”或类似的东西,只有“创建帐户”和“删除帐户”。 最佳答案 如果您想使用
我想验证用户 ID 和密码是否有效(例如 Google 帐户、Facebook 帐户、Twitter 帐户...)。我在 AccountManager 类中找到了 confirmCredentials
我是一名优秀的程序员,十分优秀!