Class: Crema::OAuth

Inherits:
Base
  • Object
show all
Defined in:
lib/crema/oauth.rb

Class Method Summary collapse

Methods inherited from Base

connection

Class Method Details

.tokenObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/crema/oauth.rb', line 3

def self.token
  response = connection.post(
    '/oauth/token',
    grant_type: 'client_credentials'.freeze,
    client_id: Crema.config.app_id,
    client_secret: Crema.config.secret
  )
  return nil unless response.success?
  JSON.parse(response.body).dig('access_token')
end