Skip to content

Commit

Permalink
fix with_token_refetch example so client is inside block
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-carvalho authored and zzooeeyy committed Apr 26, 2024
1 parent bcf7812 commit 2c726ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/shopify_app/sessions.md
Expand Up @@ -229,12 +229,12 @@ class MyController < ApplicationController
include ShopifyApp::EnsureHasSession

def index
client = ShopifyAPI::Clients::Graphql::Admin.new(session: current_shopify_session)
with_token_refetch(current_shopify_session, shopify_id_token) do
# Unauthorized errors raised within this block will initiate token exchange.
# `with_token_refetch` will store the new access token and use it
# to execute this block again.
# Any subsequent calls using the same session instance will have the new token.
client = ShopifyAPI::Clients::Graphql::Admin.new(session: current_shopify_session)
client.query(options)
end
rescue => error
Expand All @@ -261,12 +261,12 @@ class MyClass
include ShopifyApp::AdminAPI::WithTokenRefetch

def do_things(session, shopify_id_token)
client = ShopifyAPI::Clients::Graphql::Admin.new(session: session)
with_token_refetch(session, shopify_id_token) do
# Unauthorized errors raised within this block will initiate token exchange.
# `with_token_refetch` will store the new access token and use it
# to execute this block again.
# Any subsequent calls using the same session instance will have the new token.
client = ShopifyAPI::Clients::Graphql::Admin.new(session: session)
client.query(options)
end
rescue => error
Expand Down

0 comments on commit 2c726ab

Please sign in to comment.