public UserCredentials build() { return new UserCredentials( clientId, clientSecret, refreshToken, getAccessToken(), transportFactory,tokenServerUri); } }
public UserCredentials build() { return new UserCredentials( clientId, clientSecret, refreshToken, getAccessToken(), transportFactory,tokenServerUri); } }
/** * Return the stored user credentials, if applicable, or fall back to the Application Default Credentials. * * Specifically, gRPC uses the new Google OAuth library. See https://github.com/google/google-auth-library-java * * @return The com.google.auth.Credentials object. */ public GoogleCredentials getCredentials() { if (hasStoredCredential()) { return new UserCredentials(clientId, clientSecret, refreshToken); } return CredentialFactory.getApplicationDefaultCredentials(); }
@Override public Storage getCloudStorageApiClient( @NotNull String projectId, @NotNull CredentialedUser credentialedUser) { GoogleLoginState loginState = credentialedUser.getGoogleLoginState(); String clientId = loginState.fetchOAuth2ClientId(); String clientSecret = loginState.fetchOAuth2ClientSecret(); String refreshToken = loginState.fetchOAuth2RefreshToken(); return StorageOptions.newBuilder() .setProjectId(projectId) .setCredentials(new UserCredentials(clientId, clientSecret, refreshToken)) .build() .getService(); }