14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/getui/auth.rb', line 14
def generate
timestamp = ((Time.now.to_f) * 1000).to_i
resp = RestClient.post(
"https://restapi.getui.com/v1/#{Getui.app_id}/auth_sign",
JSON.dump({
timestamp: timestamp.to_s,
sign: Digest::SHA256.new.hexdigest("#{Getui.app_key}#{timestamp}#{Getui.master_secret}"),
appkey: Getui.app_key,
}),
{
"Content-Type" => "application/json"
},
)
res = JSON.parse(resp)
raise Getui::GenerateAuthTokenError.new(resp.body) unless res["result"] == "ok"
res["auth_token"]
end
|