public Credential generateCredential ( ) throws OAuthException { GoogleCredential credential = Strings . isNullOrEmpty ( this . jsonKeyFilePath ) ? generateCredentialFromClientSecrets ( ) : generateCredentialFromKeyFile ( ) ; try { if ( ! oAuth2Helper . callRefreshToken ( credential ) ) { throw new OAuthException ( "Credential could not be refreshed. A newly generated refresh token or " + "secret key may be required." ) ; } } catch ( IOException e ) { throw new OAuthException ( "Credential could not be refreshed." , e ) ; } return credential ; }
Generates a new offline credential and immediately refreshes it .