I have a public NestJs API, so no authentication required, but from this api I need to make requests to external API, this api has an auth endpoint with basic authentication (user and pass) and return a Bearer token. What is the proper way to hadle this situation? Maybe a global interceptor to intercept all request and verify the token status and if is expired make another auth request to renoval token and continue...
Ex: Get products request => My API => Verify token (valid) => continue external API => (expired) => Auth request get token (External API) => continue previous request (External API).
I would also like to know good practices to store the access token.