403 Forbidden when calling Order api on Rails app

Solved
Highlighted
Tourist
4 1 0

I was using shopify_app gem and got 403 error with this code:

ShopifyAPI::Order.all[0].total_price

I was able to create a Product:

ShopifyAPI::Product.new

or read all Products:

ShopifyAPI::Product.all[0].title

This is my configuration:

ShopifyApp.configure do |config|
  config.application_name = "My Shopify App"
  config.api_key = "MY KEY"
  config.secret = "MY SECRET"
  config.old_secret = "<old_secret>"
  config.scope = "write_products, read_products, read_all_orders, read_orders, write_orders"
  config.embedded_app = true
  config.after_authenticate_job = false
  config.api_version = "2019-04"
  config.session_repository = Shop
end

My shopify account is Basic Shopify plan. Will it affect the Order api calls?

0 Likes
Excursionist
22 0 3

Hi

 

Do you have access to read_all_orders?

 

https://help.shopify.com/en/api/getting-started/authentication/oauth/scopes

 

read_all_orders
Grants access to all orders rather than the default window of 60 days worth of orders. This OAuth scope is used in conjunction with read_orders, or write_orders. You need to request this scope from your Partner Dashboard before adding it to your app.

0 Likes
Tourist
4 1 0

Thank you for your help.

 

Unfortunately, 403 Forbidden error still occurs after I granted the Read All Orders permission from Partner Dashboard.

 

Did I miss anything else?

 

My gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.1'

gem 'rails', '~> 5.2.2'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'webpacker'
gem 'rabl'

gem 'email_validator'
gem 'slim-rails'
gem 'bcrypt', '~> 3.1.7'
gem 'mini_magick', '~> 4.8'
gem 'pundit'
gem 'rails-env-credentials'
gem 'aws-sdk', '~> 3'
gem 'shopify_app'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

 

0 Likes

Success.

Tourist
4 1 0

Hi, the issue is about Shopify plan.

I upgraded the account to the higher plan and the issue gone.

0 Likes