[Java][apache-httpclient][feign][okhttp-gson] Enable access token refresh (#17086)

* add setter of bearer token supplier

* run generate-samples.sh

* add test of bearer auth
This commit is contained in:
Tomohiko Ozawa
2023-11-18 13:46:18 +09:00
committed by GitHub
parent dc4c72c85c
commit 4bedeef643
57 changed files with 723 additions and 129 deletions

View File

@@ -14,14 +14,29 @@ public class HttpBearerAuth implements Authentication {
this.scheme = scheme;
}
/**
* Gets the token, which together with the scheme, will be sent as the value of the Authorization header.
*
* @return The bearer token
*/
public String getBearerToken() {
return tokenSupplier.get();
}
/**
* Sets the token, which together with the scheme, will be sent as the value of the Authorization header.
*
* @param bearerToken The bearer token to send in the Authorization header
*/
public void setBearerToken(String bearerToken) {
this.tokenSupplier = () -> bearerToken;
}
/**
* Sets the supplier of tokens, which together with the scheme, will be sent as the value of the Authorization header.
*
* @param tokenSupplier The supplier of bearer tokens to send in the Authorization header
*/
public void setBearerToken(Supplier<String> tokenSupplier) {
this.tokenSupplier = tokenSupplier;
}