class KeycloakAdmin::TokenClient

Public Class Methods

new(configuration, realm_client) click to toggle source
Calls superclass method KeycloakAdmin::Client::new
# File lib/keycloak-admin/client/token_client.rb, line 5
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

get() click to toggle source
# File lib/keycloak-admin/client/token_client.rb, line 19
def get
  response = execute_http do
    RestClient::Resource.new(token_url, @configuration.rest_client_options).post(
      @configuration.body_for_token_retrieval,
      @configuration.headers_for_token_retrieval
    )
  end
  TokenRepresentation.from_json(response.body)
end
realm_url() click to toggle source
# File lib/keycloak-admin/client/token_client.rb, line 15
def realm_url
  @realm_client.realm_url
end
token_url() click to toggle source
# File lib/keycloak-admin/client/token_client.rb, line 11
def token_url
  "#{realm_url}/protocol/openid-connect/token"
end