Code example for UserRecoverableAuthException

Methods: getIntent

0
                token = credentials.getToken();
                user = getUserInfo(credentials);
            } catch (UserRecoverableAuthException e) {
                if (token != null)
                    GoogleAuthUtil.invalidateToken(source.getApplicationContext(), token);
                Intent authIntent = e.getIntent();
                source.startActivityForResult(authIntent, OAUTH_GET_PERMISSIONS);
            } catch (Throwable e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            } 
        } 
 
        private Userinfo getUserInfo(GoogleAccountCredential credentials) {
            Userinfo userInfo = null;
            try { 
                Oauth2 userInfoService = new Oauth2.Builder(AndroidHttp.newCompatibleTransport(), new JacksonFactory(), credentials).build();
                userInfo = userInfoService.userinfo().get().execute();
            } catch (IOException e) {
                System.err.println("An error occurred: " + e);
            } 
            return userInfo;