Sha256: 8539e0c8c42c40c262b9ec5d564811f84cf7682462c4c0844d80d57465e1ad67
Contents?: true
Size: 984 Bytes
Versions: 6
Compression:
Stored size: 984 Bytes
Contents
# frozen_string_literal: true module ShopifyApp module AdminAPI module WithTokenRefetch def with_token_refetch(session, shopify_id_token) retrying = false if retrying.nil? yield rescue ShopifyAPI::Errors::HttpResponseError => error if error.code != 401 ShopifyApp::Logger.debug("Encountered error: #{error.code} - #{error.response.inspect}, re-raising") elsif retrying ShopifyApp::Logger.debug("Shopify API returned a 401 Unauthorized error that was not corrected " \ "with token exchange, re-raising error") else retrying = true ShopifyApp::Logger.debug("Shopify API returned a 401 Unauthorized error, exchanging token and " \ "retrying with new session") new_session = ShopifyApp::Auth::TokenExchange.perform(shopify_id_token) session.copy_attributes_from(new_session) retry end raise end end end end
Version data entries
6 entries across 6 versions & 1 rubygems