amzn / selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Apache License 2.0
580 stars 730 forks source link

AccessDeniedException - Access to requested resource is denied. #1790

Closed yizeku closed 3 years ago

yizeku commented 3 years ago

https://sellingpartnerapi-na.amazon.com/orders/v0/orders?MarketPlaceIds=A2Q3Y263D00KWC&CreatedAfter=2021/8/20 3:36:39 How to solve the authentication problem of accessing the order interface after user authorization?

image

yizeku commented 3 years ago

@jenilew, @parvathm, @ShivikaK or another dev, could you please help us out here? Thank you!

Javadebi commented 3 years ago

@jenilew, @parvathm, @ShivikaK or another dev, could you please help us out here? Thank you!

Did you migrate from mws?

yizeku commented 3 years ago

@jenilew, @parvathm, @ShivikaK or another dev, could you please help us out here? Thank you!

Did you migrate from mws? This is my first time using sp-api

yizeku commented 3 years ago

https://github.com/amzn/selling-partner-api-docs I created IAM User and Role according to the document, added Policies, and created an application to obtain tokens. https://github.com/amzn/selling-partner-api-models I using C# code to build signatures, but the error is always reported. Does anyone know how to solve it?

Javadebi commented 3 years ago

https://github.com/amzn/selling-partner-api-docs I created IAM User and Role according to the document, added Policies, and created an application to obtain tokens. https://github.com/amzn/selling-partner-api-models I using C# code to build signatures, but the error is always reported. Does anyone know how to solve it?

why did you put host and content-type inside header?

yizeku commented 3 years ago

https://github.com/amzn/selling-partner-api-docs I created IAM User and Role according to the document, added Policies, and created an application to obtain tokens. https://github.com/amzn/selling-partner-api-models I using C# code to build signatures, but the error is always reported. Does anyone know how to solve it?

why did you put host and content-type inside header?

Do you need these for your head? Do you need X-Amz-Date, Authorization, x-amz-access-token? How to solve this error? I only tested it in postman now.

Javadebi commented 3 years ago

https://github.com/amzn/selling-partner-api-docs I created IAM User and Role according to the document, added Policies, and created an application to obtain tokens. https://github.com/amzn/selling-partner-api-models I using C# code to build signatures, but the error is always reported. Does anyone know how to solve it?

why did you put host and content-type inside header?

Do you need these for your head? Do you need X-Amz-Date, Authorization, x-amz-access-token? How to solve this error? I only tested it in postman now.

no sure but remove them from the header and only keep the x-amz-access-token in header. move them in body with x-www-form type. also remove the host and content-type i don't think you need that. Do you have anything in params?

yizeku commented 3 years ago

https://github.com/amzn/selling-partner-api-docs I created IAM User and Role according to the document, added Policies, and created an application to obtain tokens. https://github.com/amzn/selling-partner-api-models I using C# code to build signatures, but the error is always reported. Does anyone know how to solve it?

why did you put host and content-type inside header?

Do you need these for your head? Do you need X-Amz-Date, Authorization, x-amz-access-token? How to solve this error? I only tested it in postman now.

no sure but remove them from the header and only keep the x-amz-access-token in header. move them in body with x-www-form type. also remove the host and content-type i don't think you need that. Do you have anything in params?

Params includes MarketPlaceIds and CreatedAfter

Javadebi commented 3 years ago

https://github.com/amzn/selling-partner-api-docs I created IAM User and Role according to the document, added Policies, and created an application to obtain tokens. https://github.com/amzn/selling-partner-api-models I using C# code to build signatures, but the error is always reported. Does anyone know how to solve it?

why did you put host and content-type inside header?

Do you need these for your head? Do you need X-Amz-Date, Authorization, x-amz-access-token? How to solve this error? I only tested it in postman now.

no sure but remove them from the header and only keep the x-amz-access-token in header. move them in body with x-www-form type. also remove the host and content-type i don't think you need that. Do you have anything in params?

Params includes MarketPlaceIds and CreatedAfter

Could you send me the link for reports example in docs?

yizeku commented 3 years ago

https://github.com/amzn/selling-partner-api-docs I created IAM User and Role according to the document, added Policies, and created an application to obtain tokens. https://github.com/amzn/selling-partner-api-models I using C# code to build signatures, but the error is always reported. Does anyone know how to solve it?

why did you put host and content-type inside header?

Do you need these for your head? Do you need X-Amz-Date, Authorization, x-amz-access-token? How to solve this error? I only tested it in postman now.

no sure but remove them from the header and only keep the x-amz-access-token in header. move them in body with x-www-form type. also remove the host and content-type i don't think you need that. Do you have anything in params?

Params includes MarketPlaceIds and CreatedAfter

Could you send me the link for reports example in docs?

https://sellingpartnerapi-na.amazon.com/orders/v0/orders?MarketPlaceIds=A2Q3Y263D00KWC&CreatedAfter=2021/8/20 7:03:22 Is that it?

Javadebi commented 3 years ago

https://github.com/amzn/selling-partner-api-docs I created IAM User and Role according to the document, added Policies, and created an application to obtain tokens. https://github.com/amzn/selling-partner-api-models I using C# code to build signatures, but the error is always reported. Does anyone know how to solve it?

why did you put host and content-type inside header?

Do you need these for your head? Do you need X-Amz-Date, Authorization, x-amz-access-token? How to solve this error? I only tested it in postman now.

no sure but remove them from the header and only keep the x-amz-access-token in header. move them in body with x-www-form type. also remove the host and content-type i don't think you need that. Do you have anything in params?

Params includes MarketPlaceIds and CreatedAfter

Could you send me the link for reports example in docs?

nvm according to this you don't need anything in headers except x-amzn-RequestId and x-amzn-RateLimit-Limit and you should put others in params

Javadebi commented 3 years ago

https://github.com/amzn/selling-partner-api-docs I created IAM User and Role according to the document, added Policies, and created an application to obtain tokens. https://github.com/amzn/selling-partner-api-models I using C# code to build signatures, but the error is always reported. Does anyone know how to solve it?

why did you put host and content-type inside header?

Do you need these for your head? Do you need X-Amz-Date, Authorization, x-amz-access-token? How to solve this error? I only tested it in postman now.

no sure but remove them from the header and only keep the x-amz-access-token in header. move them in body with x-www-form type. also remove the host and content-type i don't think you need that. Do you have anything in params?

Params includes MarketPlaceIds and CreatedAfter

Could you send me the link for reports example in docs?

nvm according to this you don't need anything in headers except x-amzn-RequestId and x-amzn-RateLimit-Limit and you should put others in params

"headers": {
              "x-amzn-RateLimit-Limit": {
                "type": "string",
                "description": "Your rate limit (requests per second) for this operation."
              },
              "x-amzn-RequestId": {
                "type": "string",
                "description": "Unique request reference ID."
              }
            },
            "x-amazon-spds-sandbox-behaviors": [
              {
                "request": {
                  "parameters": {
                    "CreatedAfter": {
                      "value": "TEST_CASE_200"
                    },
                    "MarketplaceIds": {
                      "value": [
                        "ATVPDKIKX0DER"
                      ]
                    }
                  }
                },
                "response": {
                  "payload": {
                    "CreatedBefore": "1.569521782042E9",
                    "Orders": [
                      {
                        "AmazonOrderId": "902-1845936-5435065",
                        "PurchaseDate": "1970-01-19T03:58:30Z",
                        "LastUpdateDate": "1970-01-19T03:58:32Z",
                        "OrderStatus": "Unshipped",
                        "FulfillmentChannel": "MFN",
                        "SalesChannel": "Amazon.com",
                        "ShipServiceLevel": "Std US D2D Dom",
                        "OrderTotal": {
                          "CurrencyCode": "USD",
                          "Amount": "11.01"
                        },
                        "NumberOfItemsShipped": 0,
                        "NumberOfItemsUnshipped": 1,
                        "PaymentMethod": "Other",
                        "PaymentMethodDetails": [
                          "Standard"
                        ],
                        "IsReplacementOrder": false,
                        "MarketplaceId": "ATVPDKIKX0DER",
                        "ShipmentServiceLevelCategory": "Standard",
                        "OrderType": "StandardOrder",
                        "EarliestShipDate": "1970-01-19T03:59:27Z",
                        "LatestShipDate": "1970-01-19T04:05:13Z",
                        "EarliestDeliveryDate": "1970-01-19T04:06:39Z",
                        "LatestDeliveryDate": "1970-01-19T04:15:17Z",
                        "IsBusinessOrder": false,
                        "IsPrime": false,
                        "IsGlobalExpressEnabled": false,
                        "IsPremiumOrder": false,
                        "IsSoldByAB": false,
                        "DefaultShipFromLocationAddress": {
                          "Name": "MFNIntegrationTestMerchant",
                          "AddressLine1": "2201 WESTLAKE AVE",
                          "City": "SEATTLE",
                          "StateOrRegion": "WA",
                          "PostalCode": "98121-2778",
                          "CountryCode": "US",
                          "Phone": "+1 480-386-0930 ext. 73824",
                          "AddressType": "Commercial"
                        },
                        "FulfillmentInstruction": {
                          "FulfillmentSupplySourceId": "sampleSupplySourceId"
                        },
                        "IsISPU": false
                      },
                      {
                        "AmazonOrderId": "902-8745147-1934268",
                        "PurchaseDate": "1970-01-19T03:58:30Z",
                        "LastUpdateDate": "1970-01-19T03:58:32Z",
                        "OrderStatus": "Unshipped",
                        "FulfillmentChannel": "MFN",
                        "SalesChannel": "Amazon.com",
                        "ShipServiceLevel": "Std US D2D Dom",
                        "OrderTotal": {
                          "CurrencyCode": "USD",
                          "Amount": "11.01"
                        },
                        "NumberOfItemsShipped": 0,
                        "NumberOfItemsUnshipped": 1,
                        "PaymentMethod": "Other",
                        "PaymentMethodDetails": [
                          "Standard"
                        ],
                        "IsReplacementOrder": false,
                        "MarketplaceId": "ATVPDKIKX0DER",
                        "ShipmentServiceLevelCategory": "Standard",
                        "OrderType": "StandardOrder",
                        "EarliestShipDate": "1970-01-19T03:59:27Z",
                        "LatestShipDate": "1970-01-19T04:05:13Z",
                        "EarliestDeliveryDate": "1970-01-19T04:06:39Z",
                        "LatestDeliveryDate": "1970-01-19T04:15:17Z",
                        "IsBusinessOrder": false,
                        "IsPrime": false,
                        "IsGlobalExpressEnabled": false,
                        "IsPremiumOrder": false,
                        "IsSoldByAB": false
                      }
                    ]
                  }
                }
              },
yizeku commented 3 years ago

https://github.com/amzn/selling-partner-api-docs I created IAM User and Role according to the document, added Policies, and created an application to obtain tokens. https://github.com/amzn/selling-partner-api-models I using C# code to build signatures, but the error is always reported. Does anyone know how to solve it?

why did you put host and content-type inside header?

Do you need these for your head? Do you need X-Amz-Date, Authorization, x-amz-access-token? How to solve this error? I only tested it in postman now.

no sure but remove them from the header and only keep the x-amz-access-token in header. move them in body with x-www-form type. also remove the host and content-type i don't think you need that. Do you have anything in params?

Params includes MarketPlaceIds and CreatedAfter

Could you send me the link for reports example in docs?

nvm according to this you don't need anything in headers except x-amzn-RequestId and x-amzn-RateLimit-Limit and you should put others in params

"headers": {
              "x-amzn-RateLimit-Limit": {
                "type": "string",
                "description": "Your rate limit (requests per second) for this operation."
              },
              "x-amzn-RequestId": {
                "type": "string",
                "description": "Unique request reference ID."
              }
            },
            "x-amazon-spds-sandbox-behaviors": [
              {
                "request": {
                  "parameters": {
                    "CreatedAfter": {
                      "value": "TEST_CASE_200"
                    },
                    "MarketplaceIds": {
                      "value": [
                        "ATVPDKIKX0DER"
                      ]
                    }
                  }
                },
                "response": {
                  "payload": {
                    "CreatedBefore": "1.569521782042E9",
                    "Orders": [
                      {
                        "AmazonOrderId": "902-1845936-5435065",
                        "PurchaseDate": "1970-01-19T03:58:30Z",
                        "LastUpdateDate": "1970-01-19T03:58:32Z",
                        "OrderStatus": "Unshipped",
                        "FulfillmentChannel": "MFN",
                        "SalesChannel": "Amazon.com",
                        "ShipServiceLevel": "Std US D2D Dom",
                        "OrderTotal": {
                          "CurrencyCode": "USD",
                          "Amount": "11.01"
                        },
                        "NumberOfItemsShipped": 0,
                        "NumberOfItemsUnshipped": 1,
                        "PaymentMethod": "Other",
                        "PaymentMethodDetails": [
                          "Standard"
                        ],
                        "IsReplacementOrder": false,
                        "MarketplaceId": "ATVPDKIKX0DER",
                        "ShipmentServiceLevelCategory": "Standard",
                        "OrderType": "StandardOrder",
                        "EarliestShipDate": "1970-01-19T03:59:27Z",
                        "LatestShipDate": "1970-01-19T04:05:13Z",
                        "EarliestDeliveryDate": "1970-01-19T04:06:39Z",
                        "LatestDeliveryDate": "1970-01-19T04:15:17Z",
                        "IsBusinessOrder": false,
                        "IsPrime": false,
                        "IsGlobalExpressEnabled": false,
                        "IsPremiumOrder": false,
                        "IsSoldByAB": false,
                        "DefaultShipFromLocationAddress": {
                          "Name": "MFNIntegrationTestMerchant",
                          "AddressLine1": "2201 WESTLAKE AVE",
                          "City": "SEATTLE",
                          "StateOrRegion": "WA",
                          "PostalCode": "98121-2778",
                          "CountryCode": "US",
                          "Phone": "+1 480-386-0930 ext. 73824",
                          "AddressType": "Commercial"
                        },
                        "FulfillmentInstruction": {
                          "FulfillmentSupplySourceId": "sampleSupplySourceId"
                        },
                        "IsISPU": false
                      },
                      {
                        "AmazonOrderId": "902-8745147-1934268",
                        "PurchaseDate": "1970-01-19T03:58:30Z",
                        "LastUpdateDate": "1970-01-19T03:58:32Z",
                        "OrderStatus": "Unshipped",
                        "FulfillmentChannel": "MFN",
                        "SalesChannel": "Amazon.com",
                        "ShipServiceLevel": "Std US D2D Dom",
                        "OrderTotal": {
                          "CurrencyCode": "USD",
                          "Amount": "11.01"
                        },
                        "NumberOfItemsShipped": 0,
                        "NumberOfItemsUnshipped": 1,
                        "PaymentMethod": "Other",
                        "PaymentMethodDetails": [
                          "Standard"
                        ],
                        "IsReplacementOrder": false,
                        "MarketplaceId": "ATVPDKIKX0DER",
                        "ShipmentServiceLevelCategory": "Standard",
                        "OrderType": "StandardOrder",
                        "EarliestShipDate": "1970-01-19T03:59:27Z",
                        "LatestShipDate": "1970-01-19T04:05:13Z",
                        "EarliestDeliveryDate": "1970-01-19T04:06:39Z",
                        "LatestDeliveryDate": "1970-01-19T04:15:17Z",
                        "IsBusinessOrder": false,
                        "IsPrime": false,
                        "IsGlobalExpressEnabled": false,
                        "IsPremiumOrder": false,
                        "IsSoldByAB": false
                      }
                    ]
                  }
                }
              },

image image How should I fill in these two values, like this?

Javadebi commented 3 years ago

put the body on none. remove others from header and only put x-amzn-RateLimit-Limit and x-amzn-RequestId in headers. move the params into params. These are the params:

"parameters": [
          {
            "name": "CreatedAfter",
            "in": "query",
            "description": "A date used for selecting orders created after (or at) a specified time. Only orders placed after the specified time are returned. Either the CreatedAfter parameter or the LastUpdatedAfter parameter is required. Both cannot be empty. The date must be in ISO 8601 format.",
            "required": false,
            "type": "string"
          },
          {
            "name": "CreatedBefore",
            "in": "query",
            "description": "A date used for selecting orders created before (or at) a specified time. Only orders placed before the specified time are returned. The date must be in ISO 8601 format.",
            "required": false,
            "type": "string"
          },
          {
            "name": "LastUpdatedAfter",
            "in": "query",
            "description": "A date used for selecting orders that were last updated after (or at) a specified time. An update is defined as any change in order status, including the creation of a new order. Includes updates made by Amazon and by the seller. The date must be in ISO 8601 format.",
            "required": false,
            "type": "string"
          },
          {
            "name": "LastUpdatedBefore",
            "in": "query",
            "description": "A date used for selecting orders that were last updated before (or at) a specified time. An update is defined as any change in order status, including the creation of a new order. Includes updates made by Amazon and by the seller. The date must be in ISO 8601 format.",
            "required": false,
            "type": "string"
          },
          {
            "name": "OrderStatuses",
            "in": "query",
            "description": "A list of OrderStatus values used to filter the results. Possible values: PendingAvailability (This status is available for pre-orders only. The order has been placed, payment has not been authorized, and the release date of the item is in the future.); Pending (The order has been placed but payment has not been authorized); Unshipped (Payment has been authorized and the order is ready for shipment, but no items in the order have been shipped); PartiallyShipped (One or more, but not all, items in the order have been shipped); Shipped (All items in the order have been shipped); InvoiceUnconfirmed (All items in the order have been shipped. The seller has not yet given confirmation to Amazon that the invoice has been shipped to the buyer.); Canceled (The order has been canceled); and Unfulfillable (The order cannot be fulfilled. This state applies only to Multi-Channel Fulfillment orders.).",
            "required": false,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          {
            "name": "MarketplaceIds",
            "in": "query",
            "description": "A list of MarketplaceId values. Used to select orders that were placed in the specified marketplaces.",
            "required": true,
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 50
          },
          {
            "name": "FulfillmentChannels",
            "in": "query",
            "description": "A list that indicates how an order was fulfilled. Filters the results by fulfillment channel. Possible values: FBA (Fulfillment by Amazon); SellerFulfilled (Fulfilled by the seller).",
            "required": false,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          {
            "name": "PaymentMethods",
            "in": "query",
            "description": "A list of payment method values. Used to select orders paid using the specified payment methods. Possible values: COD (Cash on delivery); CVS (Convenience store payment); Other (Any payment method other than COD or CVS).",
            "required": false,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          {
            "name": "BuyerEmail",
            "in": "query",
            "description": "The email address of a buyer. Used to select orders that contain the specified email address.",
            "required": false,
            "type": "string"
          },
          {
            "name": "SellerOrderId",
            "in": "query",
            "description": "An order identifier that is specified by the seller. Used to select only the orders that match the order identifier. If SellerOrderId is specified, then FulfillmentChannels, OrderStatuses, PaymentMethod, LastUpdatedAfter, LastUpdatedBefore, and BuyerEmail cannot be specified.",
            "required": false,
            "type": "string"
          },
          {
            "name": "MaxResultsPerPage",
            "in": "query",
            "description": "A number that indicates the maximum number of orders that can be returned per page. Value must be 1 - 100. Default 100.",
            "required": false,
            "type": "integer"
          },
          {
            "name": "EasyShipShipmentStatuses",
            "in": "query",
            "description": "A list of EasyShipShipmentStatus values. Used to select Easy Ship orders with statuses that match the specified  values. If EasyShipShipmentStatus is specified, only Amazon Easy Ship orders are returned.Possible values: PendingPickUp (Amazon has not yet picked up the package from the seller). LabelCanceled (The seller canceled the pickup). PickedUp (Amazon has picked up the package from the seller). AtOriginFC (The packaged is at the origin fulfillment center). AtDestinationFC (The package is at the destination fulfillment center). OutForDelivery (The package is out for delivery). Damaged (The package was damaged by the carrier). Delivered (The package has been delivered to the buyer). RejectedByBuyer (The package has been rejected by the buyer). Undeliverable (The package cannot be delivered). ReturnedToSeller (The package was not delivered to the buyer and was returned to the seller). ReturningToSeller (The package was not delivered to the buyer and is being returned to the seller).",
            "required": false,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          {
            "name": "NextToken",
            "in": "query",
            "description": "A string token returned in the response of your previous request.",
            "required": false,
            "type": "string"
          },
          {
            "name": "AmazonOrderIds",
            "in": "query",
            "description": "A list of AmazonOrderId values. An AmazonOrderId is an Amazon-defined order identifier, in 3-7-7 format.",
            "required": false,
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 50
          },
          {
            "name": "ActualFulfillmentSupplySourceId",
            "in": "query",
            "description": "Denotes the recommended sourceId where the order should be fulfilled from.",
            "required": false,
            "type": "string"
          },
          {
            "name": "IsISPU",
            "in": "query",
            "description": "When true, this order is marked to be picked up from a store rather than delivered.",
            "required": false,
            "type": "boolean"
          },
          {
            "name": "StoreChainStoreId",
            "in": "query",
            "description": "The store chain store identifier. Linked to a specific store in a store chain.",
            "required": false,
            "type": "string"
          }
        ],
yizeku commented 3 years ago

@Javadebi Can you give me some examples of header and body?I'm already in the header only x-amzn-RateLimit-Limit and x-amzn-RequestId, What should the value of x-amzn-requestid be filled in?What else is needed in the body? Thanks!

Javadebi commented 3 years ago

not sure but try this: image image image fill them with your credentials

yizeku commented 3 years ago

Hi @Javadebi !

image

image

I tried your method, but it still didn't work. The API returned an error of 400. Is there another way to solve it?

Thanks!

Javadebi commented 3 years ago

Hi @Javadebi !

image

image

I tried your method, but it still didn't work. The API returned an error of 400. Is there another way to solve it?

Thanks!

try moving all params into body with x-www-form type.

yizeku commented 3 years ago

Hey @Javadebi !

I just tried to put all the params into the body with x-www-form, but it was the same mistake.

Thanks for your continued patience.

Javadebi commented 3 years ago

Hey @Javadebi !

I just tried to put all the params into the body with x-www-form, but it was the same mistake.

Thanks for your continued patience.

Im sorry I couldn't help. I'll search for it and notice you if I found anything.

yizeku commented 3 years ago

I've solved it!

Javadebi commented 3 years ago

I've solved it!

What was the problem?

yizeku commented 3 years ago

Hey @Javadebi !

Parameter needs X-Amz-Security-Token.

Javadebi commented 3 years ago

Hey @Javadebi !

Parameter needs X-Amz-Security-Token.

Hi @hongtao0770 Could you share the pictures of the request? Thank you.

yizeku commented 3 years ago

Hi @Javadebi !

I didn't get it in postman.

This is my code: image

But I encountered another problem. I called orders/v0/orders successfully, but I called fba/inventory/v1/summaries returned my signature error. Do you know why?