Module: Airthings::OAuth2::ClientCredentials
- Included in:
- Configuration
- Defined in:
- lib/airthings/oauth2.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.prepended(klass) ⇒ Object
8 9 10 11 |
# File 'lib/airthings/oauth2.rb', line 8 def self.prepended(klass) super klass.attr_accessor :id, :secret end |
Instance Method Details
#access_token ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/airthings/oauth2.rb', line 13 def access_token @access_token = nil if @access_token&.expired? @access_token ||= begin client = ::OAuth2::Client.new(id, secret, token_url: "https://accounts-api.airthings.com/v1/token") client.client_credentials.get_token end @access_token.token end |