Credentials class for calling Google APIs using an API key.
Uses an API key directly in the request metadata to provide authorization.
Note: ApiKeyCredentials extends from baseCredentialsclass rather than
GoogleCredentials/OAuth2Credentials, as it does not provide an access token and is not considered
an OAuth2 credential.
Credentialscredentials=ApiKeyCredentials.create("your api key");
The callback that receives the result of the asynchronousCredentials#getRequestMetadata(java.net.URI, java.util.concurrent.Executor,
RequestMetadataCallback). Exactly one method should be called.
Interface for a service account signer. A signer for a service account is capable of signing
bytes using the private key associated with its service account.
Defines the different types of credentials that can be used for metrics.
Each credential type is associated with a label that is used for reporting purposes. Add new
enum constant only when corresponding configs established.
Credentials with typeCredentialTypeForMetrics.DO_NOT_SENDis default value for
credential implementations that do not set type specifically. It is not expected to send metrics.
[[["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-09-04 UTC."],[],[],null,["# Package com.google.auth (1.38.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.38.0 (latest)](/java/docs/reference/google-auth-library/latest/com.google.auth)\n- [1.37.1](/java/docs/reference/google-auth-library/1.37.1/com.google.auth)\n- [1.36.0](/java/docs/reference/google-auth-library/1.36.0/com.google.auth)\n- [1.35.0](/java/docs/reference/google-auth-library/1.35.0/com.google.auth)\n- [1.34.0](/java/docs/reference/google-auth-library/1.34.0/com.google.auth)\n- [1.33.1](/java/docs/reference/google-auth-library/1.33.1/com.google.auth)\n- [1.32.1](/java/docs/reference/google-auth-library/1.32.1/com.google.auth)\n- [1.31.0](/java/docs/reference/google-auth-library/1.31.0/com.google.auth)\n- [1.30.1](/java/docs/reference/google-auth-library/1.30.1/com.google.auth)\n- [1.29.1-SNAPSHOT](/java/docs/reference/google-auth-library/1.29.1-SNAPSHOT/com.google.auth)\n- [1.28.0](/java/docs/reference/google-auth-library/1.28.0/com.google.auth)\n- [1.27.0](/java/docs/reference/google-auth-library/1.27.0/com.google.auth)\n- [1.26.0](/java/docs/reference/google-auth-library/1.26.0/com.google.auth)\n- [1.25.0](/java/docs/reference/google-auth-library/1.25.0/com.google.auth)\n- [1.24.1](/java/docs/reference/google-auth-library/1.24.1/com.google.auth)\n- [1.20.0](/java/docs/reference/google-auth-library/1.20.0/com.google.auth)\n- [1.19.0](/java/docs/reference/google-auth-library/1.19.0/com.google.auth)\n- [1.18.0](/java/docs/reference/google-auth-library/1.18.0/com.google.auth)\n- [1.7.0](/java/docs/reference/google-auth-library/1.7.0/com.google.auth)\n- [1.6.1](/java/docs/reference/google-auth-library/1.6.1/com.google.auth)\n- [1.4.0](/java/docs/reference/google-auth-library/1.4.0/com.google.auth)\n- [1.3.0](/java/docs/reference/google-auth-library/1.3.0/com.google.auth) \n\nClasses\n-------\n\n### [ApiKeyCredentials](/java/docs/reference/google-auth-library/latest/com.google.auth.ApiKeyCredentials)\n\nCredentials class for calling Google APIs using an API key.\n\nUses an API key directly in the request metadata to provide authorization.\n\nNote: ApiKeyCredentials extends from base [Credentials](/java/docs/reference/google-auth-library/latest/com.google.auth.Credentials) class rather than\nGoogleCredentials/OAuth2Credentials, as it does not provide an access token and is not considered\nan OAuth2 credential. \n\n\n Credentials credentials = ApiKeyCredentials.create(\"your api key\");\n \n### [Credentials](/java/docs/reference/google-auth-library/latest/com.google.auth.Credentials)\n\nRepresents an abstract authorized identity instance.\n\nInterfaces\n----------\n\n### [RequestMetadataCallback](/java/docs/reference/google-auth-library/latest/com.google.auth.RequestMetadataCallback)\n\nThe callback that receives the result of the asynchronous Credentials#getRequestMetadata(java.net.URI, java.util.concurrent.Executor, RequestMetadataCallback). Exactly one method should be called.\n\n### [Retryable](/java/docs/reference/google-auth-library/latest/com.google.auth.Retryable)\n\n### [ServiceAccountSigner](/java/docs/reference/google-auth-library/latest/com.google.auth.ServiceAccountSigner)\n\nInterface for a service account signer. A signer for a service account is capable of signing\nbytes using the private key associated with its service account.\n\nEnums\n-----\n\n### [CredentialTypeForMetrics](/java/docs/reference/google-auth-library/latest/com.google.auth.CredentialTypeForMetrics)\n\nDefines the different types of credentials that can be used for metrics.\n\nEach credential type is associated with a label that is used for reporting purposes. Add new\nenum constant only when corresponding configs established.\n\nCredentials with type `CredentialTypeForMetrics.DO_NOT_SEND` is default value for\ncredential implementations that do not set type specifically. It is not expected to send metrics.\n\n\nSee Also: [#getLabel()](/java/docs/reference/google-auth-library/latest/com.google.auth.CredentialTypeForMetrics#com_google_auth_CredentialTypeForMetrics_getLabel__)\n\nExceptions\n----------\n\n### [ServiceAccountSigner.SigningException](/java/docs/reference/google-auth-library/latest/com.google.auth.ServiceAccountSigner.SigningException)"]]