UserRecoverableAuthException: NeedPermission

后端 未结 6 638
醉酒成梦
醉酒成梦 2020-12-01 09:16

I tried to follow tutorial: https://developers.google.com/android/guides/http-auth.

Code:

token = GoogleAuthUtil.getToken(getApplicationContext(),
           


        
6条回答
  •  离开以前
    2020-12-01 09:44

    On this docs page https://developers.google.com/+/mobile/android/sign-in the example has a good explanation for this exception.

    In particular, it looks like this line should be noted:

    Requesting an authorization code will always throw UserRecoverableAuthException on the first call to GoogleAuthUtil.getToken

    catch (UserRecoverableAuthException e) {
      // Requesting an authorization code will always throw
      // UserRecoverableAuthException on the first call to GoogleAuthUtil.getToken
      // because the user must consent to offline access to their data.  After
      // consent is granted control is returned to your activity in onActivityResult
      // and the second call to GoogleAuthUtil.getToken will succeed.
      startActivityForResult(e.getIntent(), AUTH_CODE_REQUEST_CODE);
      return;
    }
    

提交回复
热议问题