mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-19 08:17:06 +00:00
@@ -389,10 +389,20 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
* @param accessToken the access token
|
* @param accessToken the access token
|
||||||
*/
|
*/
|
||||||
public void setAccessToken(String accessToken) {
|
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()) {
|
for (Authentication auth : authentications.values()) {
|
||||||
if (auth instanceof OAuth) {
|
if (auth instanceof OAuth) {
|
||||||
((OAuth) auth).setAccessToken(accessToken);
|
((OAuth) auth).setAccessToken(tokenSupplier);
|
||||||
return;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new RuntimeException("No OAuth2 authentication configured!");
|
throw new RuntimeException("No OAuth2 authentication configured!");
|
||||||
|
|||||||
@@ -386,10 +386,20 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
* @param accessToken the access token
|
* @param accessToken the access token
|
||||||
*/
|
*/
|
||||||
public void setAccessToken(String accessToken) {
|
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()) {
|
for (Authentication auth : authentications.values()) {
|
||||||
if (auth instanceof OAuth) {
|
if (auth instanceof OAuth) {
|
||||||
((OAuth) auth).setAccessToken(accessToken);
|
((OAuth) auth).setAccessToken(tokenSupplier);
|
||||||
return;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new RuntimeException("No OAuth2 authentication configured!");
|
throw new RuntimeException("No OAuth2 authentication configured!");
|
||||||
|
|||||||
@@ -386,10 +386,20 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
* @param accessToken the access token
|
* @param accessToken the access token
|
||||||
*/
|
*/
|
||||||
public void setAccessToken(String accessToken) {
|
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()) {
|
for (Authentication auth : authentications.values()) {
|
||||||
if (auth instanceof OAuth) {
|
if (auth instanceof OAuth) {
|
||||||
((OAuth) auth).setAccessToken(accessToken);
|
((OAuth) auth).setAccessToken(tokenSupplier);
|
||||||
return;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new RuntimeException("No OAuth2 authentication configured!");
|
throw new RuntimeException("No OAuth2 authentication configured!");
|
||||||
|
|||||||
@@ -386,10 +386,20 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
* @param accessToken the access token
|
* @param accessToken the access token
|
||||||
*/
|
*/
|
||||||
public void setAccessToken(String accessToken) {
|
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()) {
|
for (Authentication auth : authentications.values()) {
|
||||||
if (auth instanceof OAuth) {
|
if (auth instanceof OAuth) {
|
||||||
((OAuth) auth).setAccessToken(accessToken);
|
((OAuth) auth).setAccessToken(tokenSupplier);
|
||||||
return;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new RuntimeException("No OAuth2 authentication configured!");
|
throw new RuntimeException("No OAuth2 authentication configured!");
|
||||||
|
|||||||
@@ -386,10 +386,20 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
* @param accessToken the access token
|
* @param accessToken the access token
|
||||||
*/
|
*/
|
||||||
public void setAccessToken(String accessToken) {
|
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()) {
|
for (Authentication auth : authentications.values()) {
|
||||||
if (auth instanceof OAuth) {
|
if (auth instanceof OAuth) {
|
||||||
((OAuth) auth).setAccessToken(accessToken);
|
((OAuth) auth).setAccessToken(tokenSupplier);
|
||||||
return;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new RuntimeException("No OAuth2 authentication configured!");
|
throw new RuntimeException("No OAuth2 authentication configured!");
|
||||||
|
|||||||
Reference in New Issue
Block a user