Class GoogleMetadataTokenProvider

java.lang.Object
fr.becpg.repo.multilingual.translation.GoogleMetadataTokenProvider
All Implemented Interfaces:
GoogleAccessTokenProvider

public class GoogleMetadataTokenProvider extends Object implements 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 Details

    • TOKEN_URI

      static final URI TOKEN_URI
    • METADATA_FLAVOR_HEADER

      static final String METADATA_FLAVOR_HEADER
      See Also:
    • METADATA_FLAVOR_VALUE

      static final String METADATA_FLAVOR_VALUE
      See Also:
    • JSON_ACCESS_TOKEN

      private static final String JSON_ACCESS_TOKEN
      See Also:
    • JSON_EXPIRES_IN

      private static final String JSON_EXPIRES_IN
      See Also:
    • EXPIRY_MARGIN

      private static final Duration EXPIRY_MARGIN
    • restTemplate

      private final org.springframework.web.client.RestTemplate restTemplate
    • clock

      private final Clock clock
    • accessToken

      private String accessToken
    • refreshAfter

      private Instant refreshAfter
  • Constructor Details

    • GoogleMetadataTokenProvider

      public GoogleMetadataTokenProvider()

      Constructor for GoogleMetadataTokenProvider.

    • GoogleMetadataTokenProvider

      GoogleMetadataTokenProvider(org.springframework.web.client.RestTemplate restTemplate, Clock clock)
  • Method Details