forked from loafle/openapi-generator-original
Compare commits
1 Commits
master
...
oauth-refr
Author | SHA1 | Date | |
---|---|---|---|
|
19eeebf083 |
@ -24,7 +24,7 @@
|
||||
{{#hasOAuthMethods}}
|
||||
#' @field access_token Access token
|
||||
#' @field oauth_client_id OAuth client ID
|
||||
#' @field oauth_secret OAuth secret
|
||||
#' @field oauth_client_secret OAuth secret
|
||||
#' @field oauth_refresh_token OAuth refresh token
|
||||
{{#authMethods}}
|
||||
{{#isOAuth}}
|
||||
@ -65,7 +65,7 @@ ApiClient <- R6::R6Class(
|
||||
# OAuth2 client ID
|
||||
oauth_client_id = NULL,
|
||||
# OAuth2 secret
|
||||
oauth_secret = NULL,
|
||||
oauth_client_secret = NULL,
|
||||
# OAuth2 refresh token
|
||||
oauth_refresh_token = NULL,
|
||||
# OAuth2
|
||||
|
@ -24,7 +24,7 @@
|
||||
{{#hasOAuthMethods}}
|
||||
#' @field access_token Access token
|
||||
#' @field oauth_client_id OAuth client ID
|
||||
#' @field oauth_secret OAuth secret
|
||||
#' @field oauth_client_secret OAuth secret
|
||||
#' @field oauth_refresh_token OAuth refresh token
|
||||
{{#authMethods}}
|
||||
{{#isOAuth}}
|
||||
@ -33,6 +33,7 @@
|
||||
#' @field oauth_token_url Token URL
|
||||
#' @field oauth_pkce Boolean flag to enable PKCE
|
||||
#' @field oauth_scopes OAuth scopes
|
||||
#' @field oauth_scopes OAuth scopes
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
{{/hasOAuthMethods}}
|
||||
@ -65,9 +66,11 @@ ApiClient <- R6::R6Class(
|
||||
# OAuth2 client ID
|
||||
oauth_client_id = NULL,
|
||||
# OAuth2 secret
|
||||
oauth_secret = NULL,
|
||||
oauth_client_secret = NULL,
|
||||
# OAuth2 refresh token
|
||||
oauth_refresh_token = NULL,
|
||||
# OAuth2 auto refresh token
|
||||
oauth_auto_refresh_token = FALSE,
|
||||
# OAuth2
|
||||
{{#authMethods}}
|
||||
{{#isOAuth}}
|
||||
@ -187,6 +190,7 @@ ApiClient <- R6::R6Class(
|
||||
# set the URL
|
||||
req <- request(url)
|
||||
|
||||
# make the call via httr, which comes with retry logic
|
||||
resp <- self$Execute(req, method, query_params, header_params, form_params,
|
||||
file_params, accepts, content_types, body, is_oauth = is_oauth,
|
||||
oauth_scopes = oauth_scopes, stream_callback = stream_callback, ...)
|
||||
@ -278,10 +282,10 @@ ApiClient <- R6::R6Class(
|
||||
|
||||
{{#hasOAuthMethods}}
|
||||
# use oauth authentication if the endpoint requires it
|
||||
if (is_oauth && !is.null(self$oauth_client_id) && !is.null(self$oauth_secret)) {
|
||||
if (is_oauth && !is.null(self$oauth_client_id) && !is.null(self$oauth_client_secret)) {
|
||||
client <- oauth_client(
|
||||
id = self$oauth_client_id,
|
||||
secret = obfuscated(self$oauth_secret),
|
||||
secret = obfuscated(self$oauth_client_secret),
|
||||
token_url = self$oauth_token_url,
|
||||
name = "{{packageName}}-oauth"
|
||||
)
|
||||
|
@ -30,13 +30,14 @@
|
||||
#' @field api_keys API keys
|
||||
#' @field access_token Access token
|
||||
#' @field oauth_client_id OAuth client ID
|
||||
#' @field oauth_secret OAuth secret
|
||||
#' @field oauth_client_secret OAuth secret
|
||||
#' @field oauth_refresh_token OAuth refresh token
|
||||
#' @field oauth_flow_type OAuth flow type
|
||||
#' @field oauth_authorization_url Authoriziation URL
|
||||
#' @field oauth_token_url Token URL
|
||||
#' @field oauth_pkce Boolean flag to enable PKCE
|
||||
#' @field oauth_scopes OAuth scopes
|
||||
#' @field oauth_scopes OAuth scopes
|
||||
#' @field bearer_token Bearer token
|
||||
#' @field timeout Default timeout in seconds
|
||||
#' @field retry_status_codes vector of status codes to retry
|
||||
@ -63,9 +64,11 @@ ApiClient <- R6::R6Class(
|
||||
# OAuth2 client ID
|
||||
oauth_client_id = NULL,
|
||||
# OAuth2 secret
|
||||
oauth_secret = NULL,
|
||||
oauth_client_secret = NULL,
|
||||
# OAuth2 refresh token
|
||||
oauth_refresh_token = NULL,
|
||||
# OAuth2 auto refresh token
|
||||
oauth_auto_refresh_token = FALSE,
|
||||
# OAuth2
|
||||
# Flow type
|
||||
oauth_flow_type = "implicit",
|
||||
@ -180,6 +183,7 @@ ApiClient <- R6::R6Class(
|
||||
# set the URL
|
||||
req <- request(url)
|
||||
|
||||
# make the call via httr, which comes with retry logic
|
||||
resp <- self$Execute(req, method, query_params, header_params, form_params,
|
||||
file_params, accepts, content_types, body, is_oauth = is_oauth,
|
||||
oauth_scopes = oauth_scopes, stream_callback = stream_callback, ...)
|
||||
@ -269,10 +273,10 @@ ApiClient <- R6::R6Class(
|
||||
req <- req %>% req_method(method)
|
||||
|
||||
# use oauth authentication if the endpoint requires it
|
||||
if (is_oauth && !is.null(self$oauth_client_id) && !is.null(self$oauth_secret)) {
|
||||
if (is_oauth && !is.null(self$oauth_client_id) && !is.null(self$oauth_client_secret)) {
|
||||
client <- oauth_client(
|
||||
id = self$oauth_client_id,
|
||||
secret = obfuscated(self$oauth_secret),
|
||||
secret = obfuscated(self$oauth_client_secret),
|
||||
token_url = self$oauth_token_url,
|
||||
name = "petstore-oauth"
|
||||
)
|
||||
|
@ -113,7 +113,7 @@ test_that("update_pet_with_form", {
|
||||
|
||||
## update pet with form
|
||||
pet_api$api_client$oauth_client_id <- "client_id_aaa"
|
||||
pet_api$api_client$oauth_secret <- "secrete_bbb"
|
||||
pet_api$api_client$oauth_client_secret <- "secrete_bbb"
|
||||
pet_api$api_client$oauth_scopes <- "write:pets read:pets"
|
||||
update_result <- pet_api$update_pet_with_form(update_pet_id, name = "pet2", status = "sold")
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#' @field api_keys API keys
|
||||
#' @field access_token Access token
|
||||
#' @field oauth_client_id OAuth client ID
|
||||
#' @field oauth_secret OAuth secret
|
||||
#' @field oauth_client_secret OAuth secret
|
||||
#' @field oauth_refresh_token OAuth refresh token
|
||||
#' @field oauth_flow_type OAuth flow type
|
||||
#' @field oauth_authorization_url Authoriziation URL
|
||||
@ -63,7 +63,7 @@ ApiClient <- R6::R6Class(
|
||||
# OAuth2 client ID
|
||||
oauth_client_id = NULL,
|
||||
# OAuth2 secret
|
||||
oauth_secret = NULL,
|
||||
oauth_client_secret = NULL,
|
||||
# OAuth2 refresh token
|
||||
oauth_refresh_token = NULL,
|
||||
# OAuth2
|
||||
|
Loading…
x
Reference in New Issue
Block a user