[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["# Class Credential.Builder (1.39.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.39.0 (latest)](/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential.Builder)\n- [1.38.2](/java/docs/reference/google-oauth-client/1.38.2/com.google.api.client.auth.oauth2.Credential.Builder)\n- [1.37.0](/java/docs/reference/google-oauth-client/1.37.0/com.google.api.client.auth.oauth2.Credential.Builder)\n- [1.36.0](/java/docs/reference/google-oauth-client/1.36.0/com.google.api.client.auth.oauth2.Credential.Builder)\n- [1.34.1](/java/docs/reference/google-oauth-client/1.34.1/com.google.api.client.auth.oauth2.Credential.Builder)\n- [1.33.3](/java/docs/reference/google-oauth-client/1.33.3/com.google.api.client.auth.oauth2.Credential.Builder)\n- [1.32.1](/java/docs/reference/google-oauth-client/1.32.1/com.google.api.client.auth.oauth2.Credential.Builder) \n\n public static class Credential.Builder\n\nCredential builder.\n\nImplementation is not thread-safe. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e Credential.Builder \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nConstructors\n------------\n\n### Builder(Credential.AccessMethod method)\n\n public Builder(Credential.AccessMethod method)\n\nMethods\n-------\n\n### addRefreshListener(CredentialRefreshListener refreshListener)\n\n public Credential.Builder addRefreshListener(CredentialRefreshListener refreshListener)\n\nAdds a listener for refresh token results.\n\nOverriding is only supported for the purpose of calling the super implementation and\nchanging the return type, but nothing else.\n\n### build()\n\n public Credential build()\n\nReturns a new credential instance.\n\n### getClientAuthentication()\n\n public final HttpExecuteInterceptor getClientAuthentication()\n\nReturns the client authentication or `null` for none (see [TokenRequest#setClientAuthentication(HttpExecuteInterceptor)](/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenRequest#com_google_api_client_auth_oauth2_TokenRequest_setClientAuthentication_com_google_api_client_http_HttpExecuteInterceptor_)).\n\n### getClock()\n\n public final Clock getClock()\n\nReturns the clock to use for expiration checks or [Clock#SYSTEM](https://cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Clock.html#com_google_api_client_util_Clock_SYSTEM) as default.\n\n### getJsonFactory()\n\n public final JsonFactory getJsonFactory()\n\nReturns the JSON factory to use for parsing response for refresh token request or `\nnull` if not refreshing tokens.\n\n### getMethod()\n\n public final Credential.AccessMethod getMethod()\n\nReturns the method of presenting the access token to the resource server (for example BearerToken.AuthorizationHeaderAccessMethod).\n\n### getRefreshListeners()\n\n public final Collection\u003cCredentialRefreshListener\u003e getRefreshListeners()\n\nReturns the listeners for refresh token results.\n\n### getRequestInitializer()\n\n public final HttpRequestInitializer getRequestInitializer()\n\nReturns the HTTP request initializer for refresh token requests to the token server or `\nnull` for none.\n\n### getTokenServerUrl()\n\n public final GenericUrl getTokenServerUrl()\n\nReturns the token server URL or `null` if not refreshing tokens.\n\n### getTransport()\n\n public final HttpTransport getTransport()\n\nReturns the HTTP transport for executing refresh token request or `null` if not\nrefreshing tokens.\n\n### setClientAuthentication(HttpExecuteInterceptor clientAuthentication)\n\n public Credential.Builder setClientAuthentication(HttpExecuteInterceptor clientAuthentication)\n\nSets the client authentication or `null` for none (see [TokenRequest#setClientAuthentication(HttpExecuteInterceptor)](/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenRequest#com_google_api_client_auth_oauth2_TokenRequest_setClientAuthentication_com_google_api_client_http_HttpExecuteInterceptor_)).\n\nOverriding is only supported for the purpose of calling the super implementation and\nchanging the return type, but nothing else.\n\n### setClock(Clock clock)\n\n public Credential.Builder setClock(Clock clock)\n\nSets the clock to use for expiration checks.\n\nThe default value is Clock.SYSTEM.\n\n### setJsonFactory(JsonFactory jsonFactory)\n\n public Credential.Builder setJsonFactory(JsonFactory jsonFactory)\n\nSets the JSON factory to use for parsing response for refresh token request or `null`\nif not refreshing tokens.\n\nOverriding is only supported for the purpose of calling the super implementation and\nchanging the return type, but nothing else.\n\n### setRefreshListeners(Collection\\\u003cCredentialRefreshListener\\\u003e refreshListeners)\n\n public Credential.Builder setRefreshListeners(Collection\u003cCredentialRefreshListener\u003e refreshListeners)\n\nSets the listeners for refresh token results.\n\nOverriding is only supported for the purpose of calling the super implementation and\nchanging the return type, but nothing else.\n\n### setRequestInitializer(HttpRequestInitializer requestInitializer)\n\n public Credential.Builder setRequestInitializer(HttpRequestInitializer requestInitializer)\n\nSets the HTTP request initializer for refresh token requests to the token server or `\nnull` for none.\n\nOverriding is only supported for the purpose of calling the super implementation and\nchanging the return type, but nothing else.\n\n### setTokenServerEncodedUrl(String tokenServerEncodedUrl)\n\n public Credential.Builder setTokenServerEncodedUrl(String tokenServerEncodedUrl)\n\nSets the encoded token server URL or `null` if not refreshing tokens.\n\nOverriding is only supported for the purpose of calling the super implementation and\nchanging the return type, but nothing else.\n\n### setTokenServerUrl(GenericUrl tokenServerUrl)\n\n public Credential.Builder setTokenServerUrl(GenericUrl tokenServerUrl)\n\nSets the token server URL or `null` if not refreshing tokens.\n\nOverriding is only supported for the purpose of calling the super implementation and\nchanging the return type, but nothing else.\n\n### setTransport(HttpTransport transport)\n\n public Credential.Builder setTransport(HttpTransport transport)\n\nSets the HTTP transport for executing refresh token request or `null` if not refreshing\ntokens.\n\nOverriding is only supported for the purpose of calling the super implementation and\nchanging the return type, but nothing else."]]