Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
talhaijaz opened this issue Oct 8, 2021 · 1 comment

Comments

@talhaijaz
Copy link

talhaijaz commented Oct 8, 2021

@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

@iamricks
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants