Class: AuthService
- Inherits:
-
Object
- Object
- AuthService
- Defined in:
- lib/services/auth_service.rb
Class Method Summary collapse
Class Method Details
.load_config ⇒ Object
7 8 9 |
# File 'lib/services/auth_service.rb', line 7 def load_config @@config ||= ConfigService.load_config('auth_keys.yml')[ConfigService.environment] rescue {} end |
.oauth_token(options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/services/auth_service.rb', line 19 def oauth_token( = {}) url = ['url'] || @@config['url'] key = ['consumer_key'] || @@config['consumer_key'] secret = ['consumer_secret'] || @@config['consumer_secret'] ActiveSupport::JSON.decode( NetUtil.call_webservices(url, 'post', "client_id=#{key}&client_secret=#{secret}&grant_type=client_credentials", { headers: {'Content-Type' => 'application/x-www-form-urlencoded'} }).body ) end |
.set_config(options = {}) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/services/auth_service.rb', line 11 def set_config( = {}) @@config['url'] = ['url'] @@config['consumer_key'] = ['consumer_key'] @@config['consumer_secret'] = ['consumer_secret'] @@config end |