forked from loafle/openapi-generator-original
Enable access token refresh (#14251)
* Enable the ruby client to support refreshing access tokens - The client can now be configured with an access token getter proc - The proc overrides the the static access token if it is set * Run generators
This commit is contained in:
@@ -62,6 +62,11 @@ module DynamicServers
|
||||
# Defines the access token (Bearer) used with OAuth2.
|
||||
attr_accessor :access_token
|
||||
|
||||
# Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
|
||||
# Overrides the access_token if set
|
||||
# @return [Proc]
|
||||
attr_accessor :access_token_getter
|
||||
|
||||
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
||||
# details will be logged with `logger.debug` (see the `logger` attribute).
|
||||
# Default to false.
|
||||
@@ -208,6 +213,12 @@ module DynamicServers
|
||||
end
|
||||
end
|
||||
|
||||
# Gets access_token using access_token_getter or uses the static access_token
|
||||
def access_token_with_refresh
|
||||
return access_token if access_token_getter.nil?
|
||||
access_token_getter.call
|
||||
end
|
||||
|
||||
# Gets Basic Auth token string
|
||||
def basic_auth_token
|
||||
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
||||
|
||||
Reference in New Issue
Block a user