Coder Social home page Coder Social logo

Comments (3)

amz-tools avatar amz-tools commented on August 23, 2024 1

Hi!

I can reproduce your error and I think I found the issue. We missed the different way of requesting an access token for grantless operations as stated here in the docs.

We have to change grant_type to "client_credentials" and use "scope" instead of "refresh_token" for all grantless operations. Its a bit complicated as we would basically have to have two different access tokens depending on the operation and as a result also two token refresh calls.

We will think about whats the best solution and will come up with a fix. For the time being you could make it work by just copying the "refreshAccessToken" function in the SellingPartner.js, rename to lets say "refreshGrantlessAccessToken" and just change the body of the request to the following:

body:JSON.stringify({
  grant_type:'client_credentials',
  scope:'sellingpartnerapi::notifications',
  client_id:this._credentials.app_client.id,
  client_secret:this._credentials.app_client.secret
})

If you then replace the await sp.refreshAccessToken in your code with await sp.refreshGrantlessAccessToken the call to getDestinations should work.

from amazon-sp-api.

michael-land avatar michael-land commented on August 23, 2024

Thanks, it works

from amazon-sp-api.

amz-tools avatar amz-tools commented on August 23, 2024

Just uploaded a new version (0.3.3) that includes support for grantless operations. Looking at your example you could now just add the scope of the grantless operation to the refresh like this:
await sp.refreshAccessToken('sellingpartnerapi::notifications')
Alternatively as it seems you didn't change the "auto_request_tokens" option (which is true by default) you could also just skip refreshAccessToken and refreshRoleCredentials calls as this will be done automatically by the client.
More information on the topic can be found in the Readme.

from amazon-sp-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.