class KeycloakAdmin::ConfigurableTokenClient
Public Class Methods
new(configuration, realm_client)
click to toggle source
Calls superclass method
KeycloakAdmin::Client::new
# File lib/keycloak-admin/client/configurable_token_client.rb, line 3 def initialize(configuration, realm_client) super(configuration) raise ArgumentError.new("realm must be defined") unless realm_client.name_defined? @realm_client = realm_client end
Public Instance Methods
exchange_with(user_access_token, token_lifespan_in_seconds)
click to toggle source
# File lib/keycloak-admin/client/configurable_token_client.rb, line 17 def exchange_with(user_access_token, token_lifespan_in_seconds) response = execute_http do RestClient::Request.execute( @configuration.rest_client_options.merge( method: :post, url: token_url, payload: { tokenLifespanInSeconds: token_lifespan_in_seconds }.to_json, headers: { Authorization: "Bearer #{user_access_token}", content_type: :json, accept: :json } ) ) end TokenRepresentation.from_json(response.body) end
realm_url()
click to toggle source
# File lib/keycloak-admin/client/configurable_token_client.rb, line 13 def realm_url @realm_client.realm_url end
token_url()
click to toggle source
# File lib/keycloak-admin/client/configurable_token_client.rb, line 9 def token_url "#{realm_url}/configurable-token" end