Search code examples
androidoauthgmail

authSubToken exception in Android


I am using the following code to get Authsubtoken from my android application; following is the code:

 GoogleAuthUtil.getToken(myCtx,  "[email protected]","oauth2:https://www.googleapis.com/auth/userinfo.profile")

With this code, I get the following exception:

com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission

How to overcome this exception?

Any help is appreciated.


Solution

  • Using this exception

    ...
    } catch (UserRecoverableAuthIOException e) {
       startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
    }
    ... 
    

    check out more here

    https://stackoverflow.com/a/14386248/760489

    https://stackoverflow.com/a/15142977/760489