Interface CredentialsHelper
- All Known Implementing Classes:
GoogleCredentialsHelper
public interface CredentialsHelper
This interface provides a method to convert a service account JSON string to a Google Credentials
object.
Additionally, contains helper methods that aid with transfering the credentials' data to the HttpRequest.Builder object
-
Method Summary
Modifier and TypeMethodDescriptioncom.google.auth.CredentialsgetGoogleCredentials(String serviceAccountJson) Converts a service account JSON string to a Google Credentials object.static HttpRequest.BuilderpopulateHeaders(HttpRequest.Builder builder, com.google.auth.Credentials credentials) Populates the headers (such as Authorization or x-goog-project) in the HttpRequest.Builder with the metadata from the credentials.
-
Method Details
-
getGoogleCredentials
com.google.auth.Credentials getGoogleCredentials(@Nullable String serviceAccountJson) throws IOException Converts a service account JSON string to a Google Credentials object.- Parameters:
serviceAccountJson- The service account JSON string.- Returns:
- A Google Credentials object.
- Throws:
IOException- when an error occurs during the conversion.
-
populateHeaders
static HttpRequest.Builder populateHeaders(HttpRequest.Builder builder, com.google.auth.Credentials credentials) throws IOException Populates the headers (such as Authorization or x-goog-project) in the HttpRequest.Builder with the metadata from the credentials.- Parameters:
builder- HttpRequest.Builder object to populate the headerscredentials- Credentials object containing the metadata- Returns:
- HttpRequest.Builder object with the headers populated
- Throws:
IOException- if an error occurs when getting the metadata from the credentials
-