mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
[Java][RestClient] Enable access token refresh (#20733)
This commit is contained in:
parent
481c69063d
commit
fb7aa580bf
@ -631,6 +631,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
|||||||
- [act coding](https://github.com/actcoding)
|
- [act coding](https://github.com/actcoding)
|
||||||
- [Adaptant Solutions AG](https://www.adaptant.io/)
|
- [Adaptant Solutions AG](https://www.adaptant.io/)
|
||||||
- [adesso SE](https://www.adesso.de/)
|
- [adesso SE](https://www.adesso.de/)
|
||||||
|
- [adorsys GmbH & Co.KG](https://adorsys.com/)
|
||||||
- [Adyen](https://www.adyen.com/)
|
- [Adyen](https://www.adyen.com/)
|
||||||
- [Agoda](https://www.agoda.com/)
|
- [Agoda](https://www.agoda.com/)
|
||||||
- [Airthings](https://www.airthings.com/)
|
- [Airthings](https://www.airthings.com/)
|
||||||
|
@ -44,6 +44,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import {{javaxPackage}}.annotation.Nullable;
|
import {{javaxPackage}}.annotation.Nullable;
|
||||||
|
|
||||||
@ -240,6 +241,21 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
throw new RuntimeException("No Bearer authentication configured!");
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set the supplier of access tokens for Bearer authentication.
|
||||||
|
*
|
||||||
|
* @param tokenSupplier the token supplier function
|
||||||
|
*/
|
||||||
|
public void setBearerToken(Supplier<String> tokenSupplier) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof HttpBearerAuth) {
|
||||||
|
((HttpBearerAuth) auth).setBearerToken(tokenSupplier);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to set username for the first HTTP basic authentication.
|
* Helper method to set username for the first HTTP basic authentication.
|
||||||
* @param username the username
|
* @param username the username
|
||||||
|
@ -46,6 +46,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import jakarta.annotation.Nullable;
|
import jakarta.annotation.Nullable;
|
||||||
|
|
||||||
@ -222,6 +223,21 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
throw new RuntimeException("No Bearer authentication configured!");
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set the supplier of access tokens for Bearer authentication.
|
||||||
|
*
|
||||||
|
* @param tokenSupplier the token supplier function
|
||||||
|
*/
|
||||||
|
public void setBearerToken(Supplier<String> tokenSupplier) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof HttpBearerAuth) {
|
||||||
|
((HttpBearerAuth) auth).setBearerToken(tokenSupplier);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to set username for the first HTTP basic authentication.
|
* Helper method to set username for the first HTTP basic authentication.
|
||||||
* @param username the username
|
* @param username the username
|
||||||
|
@ -46,6 +46,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import jakarta.annotation.Nullable;
|
import jakarta.annotation.Nullable;
|
||||||
|
|
||||||
@ -220,6 +221,21 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
throw new RuntimeException("No Bearer authentication configured!");
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set the supplier of access tokens for Bearer authentication.
|
||||||
|
*
|
||||||
|
* @param tokenSupplier the token supplier function
|
||||||
|
*/
|
||||||
|
public void setBearerToken(Supplier<String> tokenSupplier) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof HttpBearerAuth) {
|
||||||
|
((HttpBearerAuth) auth).setBearerToken(tokenSupplier);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to set username for the first HTTP basic authentication.
|
* Helper method to set username for the first HTTP basic authentication.
|
||||||
* @param username the username
|
* @param username the username
|
||||||
|
@ -46,6 +46,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import jakarta.annotation.Nullable;
|
import jakarta.annotation.Nullable;
|
||||||
|
|
||||||
@ -220,6 +221,21 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
throw new RuntimeException("No Bearer authentication configured!");
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set the supplier of access tokens for Bearer authentication.
|
||||||
|
*
|
||||||
|
* @param tokenSupplier the token supplier function
|
||||||
|
*/
|
||||||
|
public void setBearerToken(Supplier<String> tokenSupplier) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof HttpBearerAuth) {
|
||||||
|
((HttpBearerAuth) auth).setBearerToken(tokenSupplier);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to set username for the first HTTP basic authentication.
|
* Helper method to set username for the first HTTP basic authentication.
|
||||||
* @param username the username
|
* @param username the username
|
||||||
|
@ -46,6 +46,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import jakarta.annotation.Nullable;
|
import jakarta.annotation.Nullable;
|
||||||
|
|
||||||
@ -226,6 +227,21 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
throw new RuntimeException("No Bearer authentication configured!");
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set the supplier of access tokens for Bearer authentication.
|
||||||
|
*
|
||||||
|
* @param tokenSupplier the token supplier function
|
||||||
|
*/
|
||||||
|
public void setBearerToken(Supplier<String> tokenSupplier) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof HttpBearerAuth) {
|
||||||
|
((HttpBearerAuth) auth).setBearerToken(tokenSupplier);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to set username for the first HTTP basic authentication.
|
* Helper method to set username for the first HTTP basic authentication.
|
||||||
* @param username the username
|
* @param username the username
|
||||||
|
@ -46,6 +46,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import jakarta.annotation.Nullable;
|
import jakarta.annotation.Nullable;
|
||||||
|
|
||||||
@ -226,6 +227,21 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
throw new RuntimeException("No Bearer authentication configured!");
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set the supplier of access tokens for Bearer authentication.
|
||||||
|
*
|
||||||
|
* @param tokenSupplier the token supplier function
|
||||||
|
*/
|
||||||
|
public void setBearerToken(Supplier<String> tokenSupplier) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof HttpBearerAuth) {
|
||||||
|
((HttpBearerAuth) auth).setBearerToken(tokenSupplier);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to set username for the first HTTP basic authentication.
|
* Helper method to set username for the first HTTP basic authentication.
|
||||||
* @param username the username
|
* @param username the username
|
||||||
|
@ -46,6 +46,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import jakarta.annotation.Nullable;
|
import jakarta.annotation.Nullable;
|
||||||
|
|
||||||
@ -226,6 +227,21 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
throw new RuntimeException("No Bearer authentication configured!");
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set the supplier of access tokens for Bearer authentication.
|
||||||
|
*
|
||||||
|
* @param tokenSupplier the token supplier function
|
||||||
|
*/
|
||||||
|
public void setBearerToken(Supplier<String> tokenSupplier) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof HttpBearerAuth) {
|
||||||
|
((HttpBearerAuth) auth).setBearerToken(tokenSupplier);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No Bearer authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to set username for the first HTTP basic authentication.
|
* Helper method to set username for the first HTTP basic authentication.
|
||||||
* @param username the username
|
* @param username the username
|
||||||
|
Loading…
x
Reference in New Issue
Block a user