EgbertW commented on PR #25024:
URL: https://github.com/apache/beam/pull/25024#issuecomment-1384988804

   > I'm not denying the utility here, but I'm not 100% clear on how this 
addresses #25018. Could you elaborate on how this technique can be used to work 
with short-lived credentials?
   
   Of course. What I did to work with short-lived tokens is create a new header 
class, something resembling:
   
   ```
   class OauthTokenHeader extends BasicHeader {
       OIDCIDToken accessToken;
   
       ...
   
       @Override
       public String getValue() {
           if (accessToken.isExpired()) {
               accessToken.renew();
           }
           return String.format("Bearer %s", accessToken.getToken());
       }
   }
   ```
   
   Since the Elasticsearch RestClient will add the `defaultHeaders` on each 
outgoing request, it will invoke `getValue` on every request, giving the 
opportunity to check if the token has expired and if so, renew it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to