skip client id, secret validation to allow multiple auth schemas (#13126)

This commit is contained in:
William Cheng 2022-08-08 01:39:07 +08:00 committed by GitHub
parent fb29284a99
commit 3c4948ac08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 2 additions and 73 deletions

View File

@ -438,17 +438,6 @@
{{/isApiKey}} {{/isApiKey}}
{{#isOAuth}} {{#isOAuth}}
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
{{#useDefaultExceptionHandling}}
stop("oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`.")
{{/useDefaultExceptionHandling}}
{{#useRlangExceptionHandling}}
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`."))
{{/useRlangExceptionHandling}}
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "{{#scopes}}{{scope}}{{^-last}} {{/-last}}{{/scopes}}" oauth_scopes <- "{{#scopes}}{{scope}}{{^-last}} {{/-last}}{{/scopes}}"
{{/isOAuth}} {{/isOAuth}}

View File

@ -276,7 +276,7 @@ ApiClient <- R6::R6Class(
{{#hasOAuthMethods}} {{#hasOAuthMethods}}
# use oauth authentication if the endpoint requires it # use oauth authentication if the endpoint requires it
if (is_oauth) { if (is_oauth && !is.null(self$oauth_client_id) && !is.null(self$oauth_secret)) {
client <- oauth_client( client <- oauth_client(
id = self$oauth_client_id, id = self$oauth_client_id,
secret = obfuscated(self$oauth_secret), secret = obfuscated(self$oauth_secret),

View File

@ -267,7 +267,7 @@ ApiClient <- R6::R6Class(
req <- req %>% req_method(method) req <- req %>% req_method(method)
# use oauth authentication if the endpoint requires it # use oauth authentication if the endpoint requires it
if (is_oauth) { if (is_oauth && !is.null(self$oauth_client_id) && !is.null(self$oauth_secret)) {
client <- oauth_client( client <- oauth_client(
id = self$oauth_client_id, id = self$oauth_client_id,
secret = obfuscated(self$oauth_secret), secret = obfuscated(self$oauth_secret),

View File

@ -776,12 +776,6 @@ PetApi <- R6::R6Class(
} }
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `delete_pet`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `delete_pet`."))
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "write:pets read:pets" oauth_scopes <- "write:pets read:pets"
@ -887,12 +881,6 @@ PetApi <- R6::R6Class(
local_var_url_path <- "/pet/findByStatus" local_var_url_path <- "/pet/findByStatus"
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `find_pets_by_status`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `find_pets_by_status`."))
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "read:pets" oauth_scopes <- "read:pets"
@ -1011,12 +999,6 @@ PetApi <- R6::R6Class(
local_var_url_path <- "/pet/findByTags" local_var_url_path <- "/pet/findByTags"
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `find_pets_by_tags`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `find_pets_by_tags`."))
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "read:pets" oauth_scopes <- "read:pets"
@ -1522,12 +1504,6 @@ PetApi <- R6::R6Class(
local_var_url_path <- "/pet" local_var_url_path <- "/pet"
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `update_pet`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `update_pet`."))
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "write:pets read:pets" oauth_scopes <- "write:pets read:pets"
@ -1766,12 +1742,6 @@ PetApi <- R6::R6Class(
} }
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `upload_file`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `upload_file`."))
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "write:pets read:pets" oauth_scopes <- "write:pets read:pets"

View File

@ -776,12 +776,6 @@ PetApi <- R6::R6Class(
} }
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `DeletePet`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `DeletePet`."))
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "write:pets read:pets" oauth_scopes <- "write:pets read:pets"
@ -887,12 +881,6 @@ PetApi <- R6::R6Class(
local_var_url_path <- "/pet/findByStatus" local_var_url_path <- "/pet/findByStatus"
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `FindPetsByStatus`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `FindPetsByStatus`."))
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "read:pets" oauth_scopes <- "read:pets"
@ -1011,12 +999,6 @@ PetApi <- R6::R6Class(
local_var_url_path <- "/pet/findByTags" local_var_url_path <- "/pet/findByTags"
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `FindPetsByTags`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `FindPetsByTags`."))
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "read:pets" oauth_scopes <- "read:pets"
@ -1522,12 +1504,6 @@ PetApi <- R6::R6Class(
local_var_url_path <- "/pet" local_var_url_path <- "/pet"
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `UpdatePet`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `UpdatePet`."))
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "write:pets read:pets" oauth_scopes <- "write:pets read:pets"
@ -1766,12 +1742,6 @@ PetApi <- R6::R6Class(
} }
# OAuth-related settings # OAuth-related settings
if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) {
rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `UploadFile`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `UploadFile`."))
}
is_oauth <- TRUE is_oauth <- TRUE
oauth_scopes <- "write:pets read:pets" oauth_scopes <- "write:pets read:pets"