I am trying to make my Ruby on Rails do a simple request to my shopify products.
The documentations is not very clear on how to do it.
Currently Im trying to make a:
ShopifyAPI::Context.setup(
api_key: ENV.fetch('SHOPIFY_ACCESS_CLIENT_ID'),
api_secret_key: ENV.fetch('SHOPIFY_ACCESS_CLIENT_SECRET'),
host_name: ENV.fetch('SHOPIFY_SHOP_NAME'),
scope: 'read_orders,read_products,etc',
is_embedded: false, # Set to true if you are building an embedded app
is_private: false, # Set to true if you are building a private app
api_version: '2023-04' # The version of the API you would like to use
)
What is the next step? I didnt understand well how to get the session. I just want to fetch my data.
ShopifyAPI::Context.setup(
api_key: ENV.fetch('SHOPIFY_API_KEY'),
api_secret_key: ENV.fetch('SHOPIFY_API_SECRET'),
host_name: ENV.fetch('SHOPIFY_SHOP_NAME'),
scope: 'read_orders,read_products,etc',
is_embedded: true, # Set to true if you are building an embedded app
is_private: false, # Set to true if you are building a private app
api_version: '2023-07' # The version of the API you would like to use
)
session = ShopifyAPI::Auth::Session.new(shop: ENV.fetch('SHOPIFY_SHOP_NAME'),
access_token: ENV.fetch('SHOPIFY_API_SECRET'))
puts session.inspect
client = ShopifyAPI::Clients::Rest::Admin.new(session:)
client.get(path: 'orders',
query: { created_at_min: '2023-05-01T00:59:59-08:00', created_at_max: '2023-07-18T23:59:59-08:00', status: 'any',
limit: 250 })
ShopifyAPI::Errors::HttpResponseError:
{"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)","error_reference":"If you report this error, please include this id: 19897226-4b10-4884-a05f-c81768723e3e."}
C’Mon. Its a simple task here. It was not supposed to be as hard to do a simple fetch on the Rest API