Package tilda.utils.gcp
Class AuthHelper
- java.lang.Object
-
- tilda.utils.gcp.AuthHelper
-
public class AuthHelper extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.logging.log4j.Logger
LOG
-
Constructor Summary
Constructors Constructor Description AuthHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getAccessToken(com.google.auth.oauth2.GoogleCredentials creds)
static com.google.auth.oauth2.GoogleCredentials
getCredentials(java.lang.String dataProjectName, java.lang.String appName)
Given the default environment variable defined inFileUtil._DEFAULT_ENV_VAR_NAME
, looks up the value which points to a path, and then based on the project name, lookup the file "[SERVICE_ACCOUNTS_CREDENTIALS_PATH]/[dataProjectName].xxx.key.[app].json".static com.google.auth.oauth2.GoogleCredentials
getCredentials(java.lang.String envVariable, java.lang.String dataProjectName, java.lang.String appName)
Given the environment variable name passed in (default isFileUtil._DEFAULT_ENV_VAR_NAME
), looks up the value which points to a path, and then based on the project name, lookup the file "[SERVICE_ACCOUNTS_CREDENTIALS_PATH]/[dataProjectName].xxx.key.[app].json".
-
-
-
Method Detail
-
getCredentials
public static com.google.auth.oauth2.GoogleCredentials getCredentials(java.lang.String dataProjectName, java.lang.String appName) throws java.io.FileNotFoundException, java.io.IOException
Given the default environment variable defined inFileUtil._DEFAULT_ENV_VAR_NAME
, looks up the value which points to a path, and then based on the project name, lookup the file "[SERVICE_ACCOUNTS_CREDENTIALS_PATH]/[dataProjectName].xxx.key.[app].json". 'xxx' can be anything (and is optional) but is generally the first few characters of the original key file. This is done so different keys to the same project could be used in a team while keeping file names specific to the actual key file generated by GCP.- Parameters:
dataProjectName
- the name of the project, which will be made lower-case for the filename matchingapp
- the name of the app/service (e.g., bq, healthcare...), which will be made lower-case for the filename matching- Returns:
- A credentials object
- Throws:
java.io.FileNotFoundException
java.io.IOException
-
getCredentials
public static com.google.auth.oauth2.GoogleCredentials getCredentials(java.lang.String envVariable, java.lang.String dataProjectName, java.lang.String appName) throws java.io.FileNotFoundException, java.io.IOException
Given the environment variable name passed in (default isFileUtil._DEFAULT_ENV_VAR_NAME
), looks up the value which points to a path, and then based on the project name, lookup the file "[SERVICE_ACCOUNTS_CREDENTIALS_PATH]/[dataProjectName].xxx.key.[app].json". 'xxx' can be anything (and is optional) but is generally the first few characters of the original key file. This is done so different keys to the same project could be used in a team while keeping file names specific to the actual key file generated by GCP.- Parameters:
envVariable
-dataProjectName
- the name of the project, which will be made lower-case for the filename matchingapp
- the name of the app/service (e.g., bq, healthcare...), which will be made lower-case for the filename matching- Returns:
- A credentials object
- Throws:
java.io.FileNotFoundException
java.io.IOException
-
getAccessToken
public static java.lang.String getAccessToken(com.google.auth.oauth2.GoogleCredentials creds) throws java.io.IOException
- Throws:
java.io.IOException
-
-