Module: Orderspace::Endpoint::Oauth

Includes:
Structs
Included in:
Client::OauthEndpoint
Defined in:
lib/orderspace/endpoint/oauth.rb

Overview

Contains the methods to interact with the oauth endpoint.

Instance Method Summary collapse

Methods included from Structs

from, hashify, validate

Instance Method Details

#obtain_access_token(client_id, client_secret) ⇒ Orderspace::Structs::OauthCredentials

Fetches the orderspace access token to interact with the Orderspace API



18
19
20
21
22
23
# File 'lib/orderspace/endpoint/oauth.rb', line 18

def obtain_access_token(client_id, client_secret)
  response = client.request(:post, 'https://identity.orderspace.com/oauth/token',
                            { client_id:, client_secret:, grant_type: 'client_credentials' })

  Orderspace::Structs.from(JSON.parse(response.body), OauthCredentials)
end