質問

Intro:

So I use accountManager to get a token I need:

am.getAuthToken(account,
    scope,
    null,
    this,
    new OnTokenAcquired(),
    new Handler(new OnError()));

When I use "View your tasks" as the scope (just like it described here) Android shows up a permission request and tells that my application is asking for "View your tasks".

But I need to use "oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile" as the scope. When I do so, Android does not replace these URLs with the human-readable descriptions I found here.

Question:

  1. Is there anyway to force Android to replace the scope with a custom description or description defined by Google?
  2. Is there anyway to declare a custom permission and use it in the manifest so Android will ask for user's permission (such as "View your email address" and "View basic information about your account") during the installation?
  3. Is there any way achieve what I'm trying to achieve?

What I'm trying to achieve:

I just want to ask for the permission I need so users will be able to understand what kind of the permission I'm asking for.

Thanks.

役に立ちましたか?

解決

Is there anyway to force Android to replace the scope with a custom description or description defined by Google?

No it's not possible to use a custom description. When you use the Oauth2 scopes on Android versions lower than 4 (I think, I'm not sure about 3) the exact scope will be shown to the user instead of something more user friendly. On Android 4 and newer you will get a description instead so this description seems to be part of Android itself.

Is there any way achieve what I'm trying to achieve?

You could try to use Google play's GoogleAuthUtil instead of the account manager for this as it gives a much better user experience. For a comparison between using the account manager and GoogleAuthUtil see: In a nutshell what's the difference from using OAuth2 request getAuthToken and getToken

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top