Search code examples
amazon-selling-partner-api

Amazon SP-API : Getting No MWS Authorization exists when requesting authorization code via MWS token


I am getting the below error when calling the get_authorization_code method in the AuthorizationApi

AmzSpApi::ApiError (Error message: the server returns an error
HTTP status code: 400
Response headers: {"Date"=>"Tue, 19 Apr 2022 16:46:45 GMT", "Content-Type"=>"application/json", "Content-Length"=>"131", "Connection"=>"keep-alive", "x-amzn-RequestId"=>"6becf978-e4d0-4d75-b071-2033fc37da06", "x-amzn-RateLimit-Limit"=>"1.0", "x-amz-apigw-id"=>"Q1kaZGzhIAMFgKw=", "X-Amzn-Trace-Id"=>"Root=1-625ee775-4588056d54a5467f1ddac399"}
Response body: {
  "errors": [
    {
      "code": "InvalidInput",
      "message": "No MWS Authorization exists",
      "details": ""
    }
  ]
})

The MWS Token is valid since I am able to use it to successfully make calls via the MWS Api on behalf of the seller.

Stuck on this issue for a few days now so any help you can provide will be really appreciated!


Solution

  • There are a few twists and turns on this process, and the docs are unfortunately scattered around a bit.

    In short, the process is:

    1. Get all the required registration done for your app, get all the codes, keys and so forth that you need. This consists of: Developer Id, Client Id, Client Secret, Access Key, Secret Key, Seller Id, and MWS Auth Token.
    2. Once you have all that, you first need to get a migration token. (Requires client id, client secret)
    3. Use the migration token to get an authorization code. (Requires migration token, access key, secret key, developer id, seller id, MWS auth token)
    4. Use the authorization code to get LWA Refresh Token and Access Token. (Requires authorization code, client id and client secret)
    5. Use the LWA Access Token if not expired to make SP API calls, or the Refresh Token to get an updated Access Token.

    There are three resources you can use to walk you through this process: