Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,20 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @param accessToken the access token
*/
public void setAccessToken(String accessToken) {
setAccessToken(() -> accessToken);
}

/**
* Helper method to set the supplier of access tokens for OAuth2 authentication.
*
* @param tokenSupplier The supplier of access tokens
* @return ApiClient this client
*/
public ApiClient setAccessToken(Supplier<String> tokenSupplier) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setAccessToken(accessToken);
return;
((OAuth) auth).setAccessToken(tokenSupplier);
return this;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,20 @@ public void setApiKeyPrefix(String apiKeyPrefix) {
* @param accessToken the access token
*/
public void setAccessToken(String accessToken) {
setAccessToken(() -> accessToken);
}

/**
* Helper method to set the supplier of access tokens for OAuth2 authentication.
*
* @param tokenSupplier The supplier of access tokens
* @return ApiClient this client
*/
public ApiClient setAccessToken(Supplier<String> tokenSupplier) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setAccessToken(accessToken);
return;
((OAuth) auth).setAccessToken(tokenSupplier);
return this;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,20 @@ public void setApiKeyPrefix(String apiKeyPrefix) {
* @param accessToken the access token
*/
public void setAccessToken(String accessToken) {
setAccessToken(() -> accessToken);
}

/**
* Helper method to set the supplier of access tokens for OAuth2 authentication.
*
* @param tokenSupplier The supplier of access tokens
* @return ApiClient this client
*/
public ApiClient setAccessToken(Supplier<String> tokenSupplier) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setAccessToken(accessToken);
return;
((OAuth) auth).setAccessToken(tokenSupplier);
return this;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,20 @@ public void setApiKeyPrefix(String apiKeyPrefix) {
* @param accessToken the access token
*/
public void setAccessToken(String accessToken) {
setAccessToken(() -> accessToken);
}

/**
* Helper method to set the supplier of access tokens for OAuth2 authentication.
*
* @param tokenSupplier The supplier of access tokens
* @return ApiClient this client
*/
public ApiClient setAccessToken(Supplier<String> tokenSupplier) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setAccessToken(accessToken);
return;
((OAuth) auth).setAccessToken(tokenSupplier);
return this;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,20 @@ public void setApiKeyPrefix(String apiKeyPrefix) {
* @param accessToken the access token
*/
public void setAccessToken(String accessToken) {
setAccessToken(() -> accessToken);
}

/**
* Helper method to set the supplier of access tokens for OAuth2 authentication.
*
* @param tokenSupplier The supplier of access tokens
* @return ApiClient this client
*/
public ApiClient setAccessToken(Supplier<String> tokenSupplier) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setAccessToken(accessToken);
return;
((OAuth) auth).setAccessToken(tokenSupplier);
return this;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
Expand Down
Loading