GoogleAccountCredential.setSelectedAccountName(String) not working on Android 6.0 without Contacts permission

牧云@^-^@ 提交于 2019-12-23 12:59:25

问题


I'm retrieving an GoogleAccountCredential object using:

GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(
                context, Arrays.asList({ GmailScopes.MAIL_GOOGLE_COM }))
                .setBackOff(new ExponentialBackOff())
                .setSelectedAccountName(email)

with email being the Gmail account I'm using on the device.

If I retrieve the account name using credential.getSelectedAccountName the result is null.

This happens only on devices running Android Marshmallow and only if the app does NOT have the Contacts permission. As soon as I grant the Contacts permission everything works.

Why would GoogleAccountCredential.setSelectedAccountName(String) require the Contacts permission? Is it a bug or a feature?


回答1:


"contacts permission group" is required because the get_account permission required for getselectedaccountname is grouped under contacts.

that is according to https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous



来源:https://stackoverflow.com/questions/33272943/googleaccountcredential-setselectedaccountnamestring-not-working-on-android-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!