Class GoogleMetadataTokenProvider
java.lang.Object
fr.becpg.repo.multilingual.translation.GoogleMetadataTokenProvider
- All Implemented Interfaces:
GoogleAccessTokenProvider
Provides an access token of the service account attached to the pod (GKE Workload Identity) or
to the VM, read from the Google metadata server and cached until shortly before it expires.
- Author:
- matthieu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate final Clockprivate static final Durationprivate static final Stringprivate static final String(package private) static final String(package private) static final Stringprivate Instantprivate final org.springframework.web.client.RestTemplate(package private) static final URI -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for GoogleMetadataTokenProvider.GoogleMetadataTokenProvider(org.springframework.web.client.RestTemplate restTemplate, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidgetAccessToken.
-
Field Details
-
TOKEN_URI
-
METADATA_FLAVOR_HEADER
- See Also:
-
METADATA_FLAVOR_VALUE
- See Also:
-
JSON_ACCESS_TOKEN
- See Also:
-
JSON_EXPIRES_IN
- See Also:
-
EXPIRY_MARGIN
-
restTemplate
private final org.springframework.web.client.RestTemplate restTemplate -
clock
-
accessToken
-
refreshAfter
-
-
Constructor Details
-
GoogleMetadataTokenProvider
public GoogleMetadataTokenProvider()Constructor for GoogleMetadataTokenProvider.
-
GoogleMetadataTokenProvider
GoogleMetadataTokenProvider(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()
-