class LucidShopify::Authorise
Constants
- Error
Public Class Methods
new(client: Container[:client])
click to toggle source
@param client [#post_json]
# File lib/lucid_shopify/authorise.rb, line 12 def initialize(client: Container[:client]) @client = client end
Public Instance Methods
call(myshopify_domain, authorisation_code)
click to toggle source
Exchange an authorisation code for a new Shopify access token.
@param myshopify_domain [String] @param authorisation_code [String]
@return [String] the access token
@raise [Error] if the response is invalid
# File lib/lucid_shopify/authorise.rb, line 26 def call(myshopify_domain, authorisation_code) credentials = Credentials.new(myshopify_domain) data = @client.post_json(credentials, 'oauth/access_token', post_data(authorisation_code)) raise Error if data['access_token'].nil? raise Error if data['scope'] != LucidShopify.config.scope data['access_token'] end
Private Instance Methods
post_data(authorisation_code)
click to toggle source
@param authorisation_code [String]
@return [Hash]
# File lib/lucid_shopify/authorise.rb, line 42 def post_data(authorisation_code) { client_id: LucidShopify.config.api_key, client_secret: LucidShopify.config.shared_secret, code: authorisation_code, } end