You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I appreciate that it is early days for this gem, but, I'm excited by the potential of it!
I need to figure out the first steps - i.e. either direct LWA access or using our existing MWS auth tokens to access data. So I am looking at the get_authorization_code call, which should convert an existing mws auth token into an lws token.
I use the code from the read me to set up my config block:
require 'amz_sp_api'
require 'fulfillment-outbound-api-model'
require 'authorization-api-model'
AmzSpApi.configure do |config|
# config.refresh_token = nil <- this should not be needed for this call
config.client_id = 'amzn1.application-oa2-client.xxxxxxxx'
config.client_secret = 'xxxxxx'
# either use these:
config.aws_access_key_id = 'xxxx'
config.aws_secret_access_key = 'xxx+xxx'
config.region = 'eu'
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 = lambda { |access_token_key, token|
Rails.cache.write("SPAPI-TOKEN-#{access_token_key}", token[:access_token], expires_in: token[:expires_in] - 60)
}
config.get_access_token = ->(access_token_key) { Rails.cache.read("SPAPI-TOKEN-#{access_token_key}") }
end
and then do:
api = AmzSpApi::AuthorizationApiModel::AuthorizationApi.new(AmzSpApi::SpApiClient.new)
api.get_authorization_code seller_id, eu_dev_id, mws_auth_token
I get back this:
AmzSpApi::ApiError (Error message: the server returns an error)
HTTP status code: 400
Response headers: {"Server"=>"Server", "Date"=>"Sun, 06 Jun 2021 00:02:12 GMT", "Content-Type"=>"application/json;charset=UTF-8", "Content-Length"=>"109", "Connection"=>"keep-alive", "x-amz-rid"=>"xxxx", "x-amzn-RequestId"=>"xxxx-0ece-4eb0-802c-xxxx", "X-Amz-Date"=>"Sun, 06 Jun 2021 00:02:12 GMT", "x-amzn-ErrorType"=>"OA2InvalidRequestException:http://internal.amazon.com/coral/com.amazon.panda/", "Cache-Control"=>"no-cache, no-store, must-revalidate", "Pragma"=>"no-cache", "Vary"=>"Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent", "Permissions-Policy"=>"interest-cohort=()"}
Response body: {"error_description":"The request is missing a required parameter : refresh_token","error":"invalid_request"}
I am not sure how this call SHOULD work (actually examples of using the SP-API seem thin on the ground), but I don't think it should be using the refresh_token (especially when it is nil)
The text was updated successfully, but these errors were encountered:
I appreciate that it is early days for this gem, but, I'm excited by the potential of it!
I need to figure out the first steps - i.e. either direct LWA access or using our existing MWS auth tokens to access data. So I am looking at the get_authorization_code call, which should convert an existing mws auth token into an lws token.
I use the code from the read me to set up my config block:
and then do:
I get back this:
I am not sure how this call SHOULD work (actually examples of using the SP-API seem thin on the ground), but I don't think it should be using the refresh_token (especially when it is
nil
)The text was updated successfully, but these errors were encountered: