lineofflight / peddler

Amazon Selling Partner API (SP-API) in Ruby
https://lineofflight.github.io/peddler/
MIT License
307 stars 130 forks source link

Simple calls fail with 'Missing secret' when using auth tokens #100

Closed ecielam closed 6 years ago

ecielam commented 7 years ago

I am trying to use peddler with third party credentials, as documented in the README.

Using the following options to client, I am getting ArgumentError: Missing secret from the 'jeff' gem on every call I've tried, including a simple #get_service_status call. {:marketplace_id=>"AT<REDACTED>", :merchant_id=>"AF<REDACTED>", :auth_token=>"amzn.mws.<REDACTED>"}

Stack Trace:

Exception: ArgumentError: Missing secret
--
 0: <snip>/lib/ruby/gems/2.3.0/gems/jeff-2.0.0/lib/jeff.rb:75:in `secret'
 1: <snip>/lib/ruby/gems/2.3.0/gems/jeff-2.0.0/lib/jeff.rb:71:in `sign'
 2: <snip>/lib/ruby/gems/2.3.0/gems/jeff-2.0.0/lib/jeff.rb:54:in `sign_with'
 3: <snip>//lib/ruby/gems/2.3.0/gems/jeff-2.0.0/lib/jeff.rb:169:in `sign'
 4: (eval):4:in `post'
 5: <snip>/lib/ruby/gems/2.3.0/gems/peddler-1.6.3/lib/peddler/client.rb:165:in `run'
 6: <snip>/lib/ruby/gems/2.3.0/gems/peddler-1.6.3/lib/mws/sellers/client.rb:38:in `get_service_status'

If I use it as a first party call, it works fine.

I am using peddler 1.6.3 and jeff 2.0.0

ecielam commented 6 years ago

After looking a bit more at the jeff code and the MWS Amazon API docs, adding my app's aws keys to the call seems to make it work fine.

Perhaps change the readme to reflect this:

client = MWS.orders(
  aws_access_key_id: "Your AWS Access Key ID",
  aws_secret_access_key: "Your AWS Secret Access Key",
  primary_marketplace_id: "Seller's Marketplace ID",
  merchant_id: "Seller's Merchant or Seller ID",
  auth_token: "Seller's MWS Authorisation Token"
)

Thanks

hakanensari commented 6 years ago

Ah, I see. Actually, you don't need to pass the credentials if you declare them as environment variables, but the README is confusing because of the ordering in the examples. I'll fix this, thanks.