I have implemented an account manager in Android, and I'm using the peekAuthToken a lot inside the application, to get the token.
But I'm a bit confused about in the source code, in the docs it says:
Intended for use by the authenticator, not directly by applications.
Why is that, and what will be the issue using this method to get the authToken?
peekAuthToken
internally checks that two uids are equal before providng the auth token:
If the uids are different, you'll get a SecurityException.
In other words, if you're shipping the Authentication Service with the rest of your app, you should be fine. (Though I'd still recommend using getAuthToken
instead). However, if you're shipping the Authenticator in one app and want to call peekAuthToken
in another, that will not work.
https://github.com/android/platform_frameworks_base/blob/4535e11fb7010f2b104d3f8b3954407b9f330e0f/services/core/java/com/android/server/accounts/AccountManagerService.java#L1544
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With