Class GoogleServiceAccountTokenProvider
java.lang.Object
fr.becpg.repo.multilingual.translation.GoogleServiceAccountTokenProvider
- All Implemented Interfaces:
GoogleAccessTokenProvider
Access token of a service account key file, for servers outside Google Cloud that have no metadata server.
The signed JWT assertion is exchanged at the token URI of the key (RFC 7523).
- Author:
- matthieu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate static final Durationprivate final Stringprivate final Clock(package private) static final Stringprivate static final Duration(package private) static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate final PrivateKeyprivate Instantprivate final org.springframework.web.client.RestTemplate(package private) static final Stringprivate final String -
Constructor Summary
ConstructorsConstructorDescriptionGoogleServiceAccountTokenProvider(String credentialsFile) Constructor for GoogleServiceAccountTokenProvider.GoogleServiceAccountTokenProvider(org.json.JSONObject key, org.springframework.web.client.RestTemplate restTemplate, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionprivate static Stringbase64Url(byte[] bytes) (package private) Stringprivate voidgetAccessToken.(package private) static PrivateKeyparsePrivateKey(String pem) private static org.json.JSONObject
-
Field Details
-
SCOPE
- See Also:
-
GRANT_TYPE
- See Also:
-
DEFAULT_TOKEN_URI
- See Also:
-
JSON_CLIENT_EMAIL
- See Also:
-
JSON_PRIVATE_KEY
- See Also:
-
JSON_TOKEN_URI
- See Also:
-
JSON_ACCESS_TOKEN
- See Also:
-
JSON_EXPIRES_IN
- See Also:
-
ASSERTION_LIFETIME
-
EXPIRY_MARGIN
-
restTemplate
private final org.springframework.web.client.RestTemplate restTemplate -
clock
-
clientEmail
-
privateKey
-
tokenUri
-
accessToken
-
refreshAfter
-
-
Constructor Details
-
GoogleServiceAccountTokenProvider
Constructor for GoogleServiceAccountTokenProvider.
- Parameters:
credentialsFile- path of the JSON key of the service account
-
GoogleServiceAccountTokenProvider
GoogleServiceAccountTokenProvider(org.json.JSONObject key, org.springframework.web.client.RestTemplate restTemplate, Clock clock)
-
-
Method Details
-
getAccessToken
getAccessToken.
- Specified by:
getAccessTokenin interfaceGoogleAccessTokenProvider- Returns:
- a valid bearer access token
-
fetchAccessToken
private void fetchAccessToken() -
buildAssertion
String buildAssertion() -
readKey
-
parsePrivateKey
-
base64Url
-