amz_sp_api icon indicating copy to clipboard operation
amz_sp_api copied to clipboard

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

Open talhaijaz opened this issue 4 years ago • 1 comments
trafficstars

@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

talhaijaz avatar Oct 08 '21 09:10 talhaijaz

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

iamricks avatar Nov 22 '21 15:11 iamricks