撤销应用程序的帐户权限
我编写了一个代码,使用 getAuthToken() 向客户经理请求 AuthToken。第一次 - 用户需要“允许”身份验证,但以后就不需要了。
我想知道是否有办法使用 android 系统或代码撤销该权限,以帮助我调试我的程序(我的帐户已经用完了:))。卸载该应用程序没有帮助。
谢谢你,
乌迪
I wrote a code that request an AuthToken from the account manager, using the getAuthToken(). On the first time - the user needs to "Allow" the authentication, but later on there's no need to.
I want to know if there's a way to revoke that permission, using the android system or code, in order to help me debug my program (I'm running out of accounts :)). Uninstalling the app doesn't help.
Thank you,
Udi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现当您删除并重新添加帐户时,权限会被撤销,您必须再次允许它。
这是我发现的最简单的方法,除非我能找到更好的方法,否则我会将其标记为答案。
I've found that when you remove and re-add the account, then the permission is revoked, and you have to allow it again.
That's the easiest way i've found, I'm marking this as the answer unless I'll get a better one.
您可能需要完全卸载/重新安装才能有效撤销它。此外,如果您使用特定的sharedUserId,则可以在卸载后更改sharedUserId,使其看起来像不同的帐户。最后,您可以使用不同的证书对其进行签名。这就是我能够摆脱的,但是一个干净的 API 来撤销(甚至只是一个 Activity)会很好。
You might need to do a full uninstall/reinstall to in effect revoke it. Also, if you are using a specific sharedUserId, you can change the sharedUserId after you uninstall so it looks like a different account. Finally, you can sign it with a different cert. That's what I've been able to get away with, but a clean API to revoke (or even just an Activity) would be nice.
我尝试使用反射(仅用于测试目的)。
不幸的是,它抛出一个 SecurityException,因为 Android 检查调用者是一个系统应用程序...
作为参考,下面是代码:
I tried using reflexion (for testing purposes only).
Unfortunately, it throws a SecurityException because Android checks that the caller is a System app...
For reference, here is the code: