7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/keycloak-connect-ruby/token.rb', line 7
def self.generate_from_client_credentials
uri = URI("#{KeycloakConnectRuby.config.url}/realms/#{KeycloakConnectRuby.config.realm}/protocol/openid-connect/token")
params = {
'client_id' => KeycloakConnectRuby.config.client_id,
'client_secret' => KeycloakConnectRuby.config.client_secret,
'grant_type' => 'client_credentials'
}
response = Net::HTTP.post_form(uri, params)
tokens = JSON.parse(response.body)
tokens['access_token']
end
|