26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/adobe_doc_api/client.rb', line 26
def get_access_token(private_key)
jwt_payload = {
"iss" => @org_id,
"sub" => @tech_account_id,
"https://ims-na1.adobelogin.com/s/ent_documentcloud_sdk" => true,
"aud" => "https://ims-na1.adobelogin.com/c/#{@client_id}",
"exp" => (Time.now.utc + 60).to_i
}
rsa_private = OpenSSL::PKey::RSA.new File.read(private_key)
jwt_token = JWT.encode jwt_payload, rsa_private, "RS256"
connection = Faraday.new do |conn|
conn.response :json, content_type: "application/json"
end
response = connection.post JWT_URL do |req|
req.params["client_id"] = @client_id
req.params["client_secret"] = @client_secret
req.params["jwt_token"] = jwt_token
end
return response.body["access_token"]
end
|