简体   繁体   中英

Is there an easy way to use oAuth2 without an AccountManager?

I'd like to use a web service in my app which uses oAuth2. The official Android docs suggest I use AccountManager for this, but it also states that third party apps aren't able to use the ACCOUNT_MANAGER permission. When adding the permission to my manifest:

android.permission.ACCOUNT_MANAGER

I get the following error: Permission is only granted to system apps

So how do I actually work with oAuth if I can't use AccountManager?

These are the pre-Marshmallow permissions you would need to act as a client of AccountManager .

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />

You can find out which calls need which permissions by looking at the AccountManager documentation .

ACCOUNT_MANAGER permission is for the service that responds to your app's requests. That gives it ability to access authenticators directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM