91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/edmentum_client.rb', line 91
def self.token(config)
url = "https://auth.edmentum.com/connect/token"
req_opts = {
method: :post,
headers: {
"Authorization": "#{config.basic_auth_token}",
"Content-Type": "application/x-www-form-urlencoded"
},
body: {
grant_type: "password",
username: config.username,
password: config.password,
scope: "openid profile offline_access role api_web"
}
}
request = Typhoeus::Request.new(url, req_opts)
response = request.run
if response.success?
"Bearer " + JSON.parse(response.body)["access_token"]
else
raise "Authentication failed"
end
end
|