Class: ShopifyApp::Auth::TokenExchange
- Inherits:
-
Object
- Object
- ShopifyApp::Auth::TokenExchange
- Defined in:
- lib/shopify_app/auth/token_exchange.rb
Instance Attribute Summary collapse
-
#id_token ⇒ Object
readonly
Returns the value of attribute id_token.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id_token) ⇒ TokenExchange
constructor
A new instance of TokenExchange.
- #perform ⇒ Object
Constructor Details
#initialize(id_token) ⇒ TokenExchange
Returns a new instance of TokenExchange.
12 13 14 |
# File 'lib/shopify_app/auth/token_exchange.rb', line 12 def initialize(id_token) @id_token = id_token end |
Instance Attribute Details
#id_token ⇒ Object (readonly)
Returns the value of attribute id_token.
6 7 8 |
# File 'lib/shopify_app/auth/token_exchange.rb', line 6 def id_token @id_token end |
Class Method Details
.perform(id_token) ⇒ Object
8 9 10 |
# File 'lib/shopify_app/auth/token_exchange.rb', line 8 def self.perform(id_token) new(id_token).perform end |
Instance Method Details
#perform ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/shopify_app/auth/token_exchange.rb', line 16 def perform domain = ShopifyAPI::Auth::JwtPayload.new(id_token).shopify_domain Logger.info("Performing Token Exchange for [#{domain}] - (Offline)") session = exchange_token( shop: domain, id_token: id_token, requested_token_type: ShopifyAPI::Auth::TokenExchange::RequestedTokenType::OFFLINE_ACCESS_TOKEN, ) if online_token_configured? Logger.info("Performing Token Exchange for [#{domain}] - (Online)") session = exchange_token( shop: domain, id_token: id_token, requested_token_type: ShopifyAPI::Auth::TokenExchange::RequestedTokenType::ONLINE_ACCESS_TOKEN, ) end ShopifyApp.configuration.post_authenticate_tasks.perform(session) session end |