This is traditional way to obtain token from GoogleApiClient used in Google+ login:
String token = GoogleAuthUtil.getToken(apiClient.getContext(), getAccountNameFromGoogle(apiClient), SCOPE);
However, GetAccountNameFromGoogle
method requires android.permission.GET_ACCOUNTS
permission and in Android M Developer Preview 3, this permission is now marked as dangerous and grouped into contacts group. That means that if someone wants to login into my app he needs need to grant my app full contacts permissions which is a bit overkill.
Is there a way to achieve this without GET_ACCOUNTS
permission?
One potential answer I found is obtaining account name from AccountPicker, but that forces user to pick his account it twice (once for Google Plus authentication and once for AccountPicker) which is also not very friendly solution.
android.permission.GET_ACCOUNTS
permission. I found that it works on Lollipop and has a problem on M preview 3 when running toPlus.PeopleApi.getCurrentPerson(mGoogleApiClient).getDisplayName();
, it will get null pointer. I have report the issue here.