@lokalise/backend-expert-http-client
v2.2.0
Published
Utility library with the client for communication with Expert API
Maintainers
Keywords
Readme
Lokalise Expert API Client
Utility library with the client for communication with Expert API
Service-to-service bearer headers
createOAuth2S2STokenProvider returns a TokenProvider that fetches and caches an OAuth2
client-credentials token. resolveBearerHeaders turns such a provider into the authorization
header for an outgoing call to another service:
const tokenProvider = createOAuth2S2STokenProvider({ serverUrl, clientId, clientSecret })
const headers = {
'content-type': 'application/json',
...(await resolveBearerHeaders(tokenProvider, requestContext)),
}When the provider fails, a TokenProviderError is thrown before any request is sent. The request
context is required so that a failure is always logged with the request it belongs to.
