【发布时间】:2021-08-03 04:58:18
【问题描述】:
我一直在尝试使用 Ruby gem amz_sp_api 访问新的 Amazon SP-API@
我已按照有关创建 IAM 用户以及获取我认为正确的令牌的所有说明进行操作。但我仍然收到以下错误:
"message": "Access to requested resource is denied.",
"code": "MissingAuthenticationToken"
这是我正在使用的代码:
require 'amz_sp_api'
require 'product-pricing-api-model'
require 'fulfillment-outbound-api-model'
require 'byebug'
require 'aws-sdk-core'
AmzSpApi.configure do |config|
config.refresh_token = 'long string'
config.client_id = 'amzn1.application-oa2-client.123'
config.client_secret = 'secret'
config.credentials_provider = Aws::STS::Client.new(
region: AmzSpApi::SpConfiguration::AWS_REGION_MAP['na'],
access_key_id: 'key',
secret_access_key: 'secret_key'
).assume_role(role_arn: 'arn:aws:iam::123:role/SellerAPIRole', role_session_name: SecureRandom.uuid)
config.timeout = 20 # seconds
config.debugging = true
end
api_instance = AmzSpApi::FulfillmentOutboundApiModel::FbaOutboundApi.new
marketplace_id = 'ATVPDKIKX0DER'
begin
result = api_instance.get_features(marketplace_id)
pp result
rescue AmzSpApi::FulfillmentOutboundApiModel::ApiError => e
puts "Exception when calling FbaOutboundApi->get_features: #{e}"
end
我得到回报
Exception when calling FbaOutboundApi->get_features: Error message: the server returns an error
HTTP status code: 403
Response headers: {"Date"=>"Wed, 12 May 2021 19:23:39 GMT", "Content-Type"=>"application/json", "Content-Length"=>"135", "Connection"=>"keep-alive", "x-amzn-RequestId"=>"123", "x-amzn-ErrorType"=>"MissingAuthenticationTokenException", "x-amz-apigw-id"=>"something"}
Response body: {
"errors": [
{
"message": "Access to requested resource is denied.",
"code": "MissingAuthenticationToken"
}
]
}
还有其他人看到这个问题吗?我已经完成了设置 IAM 用户和所有这些混乱的广泛的入职流程。
【问题讨论】:
-
AmzSpApi::SpConfiguration::AWS_REGION_MAP['na']返回正确的区域?因为曾经让我发疯... -
是的,当我检查那个客户时,我看到
@host=\"sellingpartnerapi-na.amazon.com\", @base_path=\"https://sellingpartnerapi-na.amazon.com/\",似乎是正确的 -
根据aws.amazon.com/de/premiumsupport/knowledge-center/…,如果您尝试访问未定义的函数,也会发生此错误。在您的情况下,您尝试使用
get_features。这是在某个地方记录的吗?谷歌快速搜索什么也没给我 -
我希望!!我一直在使用这个方法/类列表。如果你之前没有看到它,它会很有帮助rubydoc.info/gems/amz_sp_api/…
-
但是是的
get_features在那里..
标签: ruby selling-partner-api amz-sp-api