Module: LuluApi::Client::Auth

Included in:
LuluApi::Client
Defined in:
lib/lulu_api/client/auth.rb

Instance Method Summary collapse

Instance Method Details

#fetch_tokenObject



5
6
7
8
9
10
11
12
# File 'lib/lulu_api/client/auth.rb', line 5

def fetch_token
  body = "grant_type=client_credentials&client_key=#{@client_key}&client_secret=#{@client_secret}"
  headers = {'Authorization' => @auth_string, 'Content-Type' => 'application/x-www-form-urlencoded' }
  response = self.class.post("/auth/realms/glasstree/protocol/openid-connect/token", { headers: headers, body: body })
  @token = response.parsed_response['access_token']

  self.class.headers 'Authorization' => "Bearer #{@token}"
end