Class: KeycloakAdmin::TokenClient
- Inherits:
-
Client
- Object
- Client
- KeycloakAdmin::TokenClient
show all
- Defined in:
- lib/keycloak-admin/client/token_client.rb
Instance Method Summary
collapse
Methods inherited from Client
#create_payload, #created_id, #current_token, #execute_http, #headers, #server_url
Constructor Details
#initialize(configuration, realm_client) ⇒ TokenClient
Returns a new instance of TokenClient.
5
6
7
8
9
|
# 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
|
Instance Method Details
#get ⇒ Object
19
20
21
22
23
24
25
26
27
|
# 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.
)
end
TokenRepresentation.from_json(response.body)
end
|
#realm_url ⇒ Object
15
16
17
|
# File 'lib/keycloak-admin/client/token_client.rb', line 15
def realm_url
@realm_client.realm_url
end
|
#token_url ⇒ Object
11
12
13
|
# File 'lib/keycloak-admin/client/token_client.rb', line 11
def token_url
"#{realm_url}/protocol/openid-connect/token"
end
|