AmzSpApi::FeedsApiModel::FeedsApi.new(AmzSpApi::SpApiClient.new) - Unauthorised error
Closed this issue · 1 comments
require 'amz_sp_api'
require 'fulfillment-outbound-api-model'
require 'feeds-api-model'
AmzSpApi.configure do |config|
config.refresh_token = "xxxx"
config.client_id = "xxxxx"
config.client_secret = "88888"
# either use these:
config.aws_access_key_id = "xxxx"
config.aws_secret_access_key = "xxxx"
# OR config.credentials_provider which is passed along to https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html, e.g.
# require 'aws-sdk-core'
# config.credentials_provider = Aws::STS::Client.new(
# region: AmzSpApi::SpConfiguration::AWS_REGION_MAP['eu'],
# access_key_id: ,
# secret_access_key:
# ).assume_role(role_arn: , role_session_name: SecureRandom.uuid)
config.region = 'na'
config.timeout = 20 # seconds
config.debugging = true
end
feeds = AmzSpApi::FeedsApiModel::FeedsApi.new(AmzSpApi::SpApiClient.new)
response = feeds.create_feed_document({"contentType" => 'UTF-8'})
upload completely sent off: 23 out of 23 bytes
HTTP/1.1 403 Forbidden
Date: Mon, 04 Oct 2021 19:11:07 GMT
Content-Type: application/json
Content-Length: 141
Connection: keep-alive
x-amzn-RequestId: dea56827-9ec5-4152-ac1e-f8ed94b6c23a
x-amzn-ErrorType: AccessDeniedException
x-amz-apigw-id: Gsm31FkroAMFtQg=
Connection #1 to host sellingpartnerapi-na.amazon.com left intact
D, [2021-10-05T00:11:07.676009 #6621] DEBUG -- : HTTP response body BEGIN
{
"errors": [
{
"message": "Access to requested resource is denied.",
"code": "Unauthorized",
"details": ""
}
]
}
END
AmzSpApi::ApiError: Error message: the server returns an error
HTTP status code: 403
Response headers: {"Date"=>"Mon, 04 Oct 2021 19:11:07 GMT", "Content-Type"=>"application/json", "Content-Length"=>"141", "Connection"=>"keep-alive", "x-amzn-RequestId"=>"dea56827-9ec5-4152-ac1e-f8ed94b6c23a", "x-amzn-ErrorType"=>"AccessDeniedException", "x-amz-apigw-id"=>"Gsm31FkroAMFtQg="}
Response body: {
"errors": [
{
"message": "Access to requested resource is denied.",
"code": "Unauthorized",
"details": ""
}
]
}
from /Users/user/.rvm/gems/ruby-2.4.3/gems/amz_sp_api-0.2.2/lib/api_client.rb:64:in call_api' from /Users/user/.rvm/gems/ruby-2.4.3/gems/amz_sp_api-0.2.2/lib/sp_api_client.rb:18:in
call_api'
from /Users/user/.rvm/gems/ruby-2.4.3/gems/amz_sp_api-0.2.2/lib/feeds-api-model/api/feeds_api.rb:172:in create_feed_document_with_http_info' from /Users/user/.rvm/gems/ruby-2.4.3/gems/amz_sp_api-0.2.2/lib/feeds-api-model/api/feeds_api.rb:134:in
create_feed_document'
from (irb):31
from /Users/user/.rvm/rubies/ruby-2.4.3/bin/irb:11:in `
2.4.3 :032 >