The public keys are loaded from the public certificates endpoint at #getPublicCertsEncodedUrl and cached in this instance. Therefore, for maximum efficiency,
applications should use a single globally-shared instance of the GooglePublicKeysManager.
For efficiency, an in-memory cache of the public keys is used here. If this method is called
for the first time, or the certificates have expired since last time it has been called (or are
within 5 minutes of expiring), #refresh() will be called before returning the value.
This method is automatically called from #getPublicKeys() if the public keys have
not yet been initialized or if the expiration time is very close, so normally this doesn't need
to be called. Only call this method to explicitly force the public keys to be updated.
[[["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-28 UTC."],[],[],null,["# Class GooglePublicKeysManager (2.8.1)\n\nVersion latestkeyboard_arrow_down\n\n- [2.8.1 (latest)](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)\n- [2.8.0](/java/docs/reference/google-api-client/2.8.0/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)\n- [2.7.2](/java/docs/reference/google-api-client/2.7.2/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)\n- [2.6.0](/java/docs/reference/google-api-client/2.6.0/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)\n- [2.5.1](/java/docs/reference/google-api-client/2.5.1/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)\n- [2.4.1](/java/docs/reference/google-api-client/2.4.1/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)\n- [2.1.2](/java/docs/reference/google-api-client/2.1.2/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)\n- [2.0.1](/java/docs/reference/google-api-client/2.0.1/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)\n- [1.35.2](/java/docs/reference/google-api-client/1.35.2/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)\n- [1.34.1](/java/docs/reference/google-api-client/1.34.1/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)\n- [1.33.4](/java/docs/reference/google-api-client/1.33.4/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager) \n\n public class GooglePublicKeysManager\n\nBeta \n\nThread-safe Google public keys manager.\n\nThe public keys are loaded from the public certificates endpoint at [#getPublicCertsEncodedUrl](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager#com_google_api_client_googleapis_auth_oauth2_GooglePublicKeysManager_getPublicCertsEncodedUrl_) and cached in this instance. Therefore, for maximum efficiency,\napplications should use a single globally-shared instance of the [GooglePublicKeysManager](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager). \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e GooglePublicKeysManager \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### GooglePublicKeysManager(GooglePublicKeysManager.Builder builder)\n\n protected GooglePublicKeysManager(GooglePublicKeysManager.Builder builder)\n\n### GooglePublicKeysManager(HttpTransport transport, JsonFactory jsonFactory)\n\n public GooglePublicKeysManager(HttpTransport transport, JsonFactory jsonFactory)\n\nMethods\n-------\n\n### getClock()\n\n public final Clock getClock()\n\nReturns the clock.\n\n### getExpirationTimeMilliseconds()\n\n public final long getExpirationTimeMilliseconds()\n\nReturns the expiration time in milliseconds to be used with [Clock#currentTimeMillis()](https://cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Clock.html#com_google_api_client_util_Clock_currentTimeMillis_)\nor `0` for none.\n\n### getJsonFactory()\n\n public final JsonFactory getJsonFactory()\n\nReturns the JSON factory.\n\n### getPublicCertsEncodedUrl()\n\n public final String getPublicCertsEncodedUrl()\n\nReturns the public certificates encoded URL.\n\n### getPublicKeys()\n\n public final List\u003cPublicKey\u003e getPublicKeys()\n\nReturns an unmodifiable view of the public keys.\n\nFor efficiency, an in-memory cache of the public keys is used here. If this method is called\nfor the first time, or the certificates have expired since last time it has been called (or are\nwithin 5 minutes of expiring), [#refresh()](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager#com_google_api_client_googleapis_auth_oauth2_GooglePublicKeysManager_refresh__) will be called before returning the value.\n\n### getTransport()\n\n public final HttpTransport getTransport()\n\nReturns the HTTP transport.\n\n### refresh()\n\n public GooglePublicKeysManager refresh()\n\nForces a refresh of the public certificates downloaded from [#getPublicCertsEncodedUrl](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager#com_google_api_client_googleapis_auth_oauth2_GooglePublicKeysManager_getPublicCertsEncodedUrl_).\n\nThis method is automatically called from [#getPublicKeys()](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager#com_google_api_client_googleapis_auth_oauth2_GooglePublicKeysManager_getPublicKeys__) if the public keys have\nnot yet been initialized or if the expiration time is very close, so normally this doesn't need\nto be called. Only call this method to explicitly force the public keys to be updated."]]