public class GdchCredentials extends GoogleCredentialsStatic Methods
fromStream(InputStream credentialsStream)
public static GdchCredentials fromStream(InputStream credentialsStream)Returns credentials defined by a GdchCredentials key file in JSON format from the Google Developers Console.
Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information, refer to {@see documentation}.
| Parameter | |
|---|---|
| Name | Description |
credentialsStream |
InputStreamthe stream with the credential definition. |
| Returns | |
|---|---|
| Type | Description |
GdchCredentials |
the credential defined by the credentialsStream. |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if the credential cannot be created from the stream. |
fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory)
public static GdchCredentials fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory)Returns credentials defined by a GdchCredentials key file in JSON format from the Google Developers Console.
Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information, refer to {@see documentation}.
| Parameters | |
|---|---|
| Name | Description |
credentialsStream |
InputStreamthe stream with the credential definition. |
transportFactory |
HttpTransportFactoryHTTP transport factory, creates the transport used to get access tokens. |
| Returns | |
|---|---|
| Type | Description |
GdchCredentials |
the credential defined by the credentialsStream. |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if the credential cannot be created from the stream. |
newBuilder()
public static GdchCredentials.Builder newBuilder()| Returns | |
|---|---|
| Type | Description |
GdchCredentials.Builder |
|
Methods
createWithGdchAudience(String apiAudience)
public GdchCredentials createWithGdchAudience(String apiAudience)Create a copy of GDCH credentials with the specified audience.
| Parameter | |
|---|---|
| Name | Description |
apiAudience |
StringThe intended audience for GDCH credentials. |
| Returns | |
|---|---|
| Type | Description |
GdchCredentials |
|
createWithGdchAudience(URI apiAudience)
public GdchCredentials createWithGdchAudience(URI apiAudience)This method is obsolete. Please use #createWithGdchAudience(String)} instead. Create a copy of GDCH credentials with the specified audience.
| Parameter | |
|---|---|
| Name | Description |
apiAudience |
URIThe intended audience for GDCH credentials. |
| Returns | |
|---|---|
| Type | Description |
GdchCredentials |
|
equals(Object obj)
public boolean equals(Object obj)| Parameter | |
|---|---|
| Name | Description |
obj |
Object |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
getApiAudience()
public final URI getApiAudience()NOTE: This method is obsolete, please use #getGdchAudience() instead. Returns a URI representation of the underlying audience string set for this credentials object. This method may fail if the underlying audience string does not conform to a URI format.
| Returns | |
|---|---|
| Type | Description |
URI |
a URI object representing the audience of the credentials, or null if no audience has been set or if the audience string is not a valid URI. |
getCaCertPath()
public final String getCaCertPath()| Returns | |
|---|---|
| Type | Description |
String |
|
getGdchAudience()
public final String getGdchAudience()Returns the underlying audience string set for this credentials object.
| Returns | |
|---|---|
| Type | Description |
String |
the audience string, or null if no audience has been set. |
getPrivateKey()
public final PrivateKey getPrivateKey()| Returns | |
|---|---|
| Type | Description |
PrivateKey |
|
getPrivateKeyId()
public final String getPrivateKeyId()| Returns | |
|---|---|
| Type | Description |
String |
|
getProjectId()
public final String getProjectId()The projectId value for a Credential type. Since not all GoogleCredentials subclass have a projectId associated, the projectId may be null. A subset of GoogleCredentials subclasses will override to return their projectId.
| Returns | |
|---|---|
| Type | Description |
String |
the projectId set in the GDCH SA Key file or the user set projectId |
getServiceIdentityName()
public final String getServiceIdentityName()| Returns | |
|---|---|
| Type | Description |
String |
|
getTokenServerUri()
public final URI getTokenServerUri()| Returns | |
|---|---|
| Type | Description |
URI |
|
getTransportFactory()
public final HttpTransportFactory getTransportFactory()| Returns | |
|---|---|
| Type | Description |
HttpTransportFactory |
|
hashCode()
public int hashCode()| Returns | |
|---|---|
| Type | Description |
int |
|
refreshAccessToken()
public AccessToken refreshAccessToken()Refresh the OAuth2 access token by getting a new access token using a JSON Web Token (JWT).
For GDCH credentials, this class creates a self-signed JWT, and sends to the GDCH authentication endpoint (tokenServerUri) to exchange an access token for the intended api audience (apiAudience).
| Returns | |
|---|---|
| Type | Description |
AccessToken |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
toBuilder()
public GdchCredentials.Builder toBuilder()| Returns | |
|---|---|
| Type | Description |
GdchCredentials.Builder |
|
toString()
public String toString()Returns a string representation of this credential, including request metadata and access token.
Security Warning: The output of this method includes the request metadata which contains the raw Bearer access token, and the raw access token value. Do not log this output in production environments as it may expose sensitive credentials.
| Returns | |
|---|---|
| Type | Description |
String |
|