ericcj / amz_sp_api

AmzSpApi - Unofficial Ruby gem for the Selling Partner APIs (SP-API)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting "Access to requested resource is denied error" every time trying to hit the api.

talhaijaz opened this issue · comments

@mreinsch @ericcj

AmzSpApi.configure do |config|
config.refresh_token = "Token generated from generate token button in my app for united states region"
config.client_id = "Cleint id of app"
config.client_secret = "Client secret of app"
# either use these:
config.aws_access_key_id = "Access Key Id From users page in aws console"
config.aws_secret_access_key = "Access secret that generates when we first create an access key"
config.region = 'na' // because my refresh token is generated in US region
config.timeout = 20 # seconds
# config.debugging = true
# optional lambdas for caching LWA access token instead of requesting it each time, e.g.:
config.save_access_token = -> (access_token_key, token) do
Rails.cache.write("SPAPI-TOKEN-#{access_token_key}", token[:access_token], expires_in: token[:expires_in] - 60)
end
config.get_access_token = -> (access_token_key) { Rails.cache.read("SPAPI-TOKEN-#{access_token_key}") }
end
begin
api = AmzSpApi::FulfillmentOutboundApiModel::FbaOutboundApi.new(AmzSpApi::SpApiClient.new)
p api.list_all_fulfillment_orders.payload
rescue AmzSpApi::ApiError => e
puts "Exception when calling SP-API: #{e}"
end
end

Authentication definitely works, make sure you are using credentials that have sufficient and that the store is not suspended