mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-19 08:37:10 +00:00
@@ -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!");
|
||||
|
||||
@@ -386,10 +386,20 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
* @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!");
|
||||
|
||||
@@ -386,10 +386,20 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
* @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!");
|
||||
|
||||
@@ -386,10 +386,20 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
* @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!");
|
||||
|
||||
@@ -386,10 +386,20 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
* @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!");
|
||||
|
||||
Reference in New Issue
Block a user