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
591 stars 729 forks source link

AES 256 Encryption for upload document through Feeds API #38

Closed mashhood1995 closed 2 years ago

mashhood1995 commented 3 years ago

Hi , I am trying to connect with feeds api for uploading inventory information. I am successfully able to retrieve key and initializationVector . But when i use those keys in online tool for AES encryption . I get this error "Length of secret key should be 32 for 256 bits key size" . When i try aes js library in my javascript code , I get the this error "Error: invalid initialation vector size (must be 16 bytes)". I have tried different things e.g decoded key and initialation from base64 to utf-8 ,base64 to hex etc but it doesn't work and i get same error . Does anyone know what is the issue ? Am i missing out something ?

marketplacehub-com commented 3 years ago

You must convert initializationVector string from base64 string to byte array. And use it for encryption.

mashhood1995 commented 3 years ago

Thanks . shall i convert key to byte array as well ?

marketplacehub-com commented 3 years ago

sure. in the same way, from base64 string to byte array.

MrYing commented 3 years ago

@esalesplatform What is the return value you get after uploading? I have a similar problem, but my problem is the XML format. How to correct it is still this error Please have a look my xml: <?xml version="1.0" encoding="UTF-8"?> <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.02</DocumentVersion> <MerchantIdentifier>XXXXXXXX</MerchantIdentifier> </Header> <MessageType>Product</MessageType> <PurgeAndReplace>true</PurgeAndReplace> <Message> <MessageID>10001</MessageID> <OperationType>Update</OperationType> <Product> <SKU>XXXXXX</SKU> <ProductTaxCode>A_GEN_TAX</ProductTaxCode> <LaunchDate>2021-01-05T08:17:01</LaunchDate> <DescriptionData> <Title> Test</Title> <Brand>Test</Brand> <Description>This is a test case ,please agree this product publish</Description> <BulletPoint>made in China</BulletPoint> <BulletPoint>500 thread count</BulletPoint> <BulletPoint>plain weave (percale)</BulletPoint> <BulletPoint>100% Egyptian cotton</BulletPoint> <Manufacturer>Test</Manufacturer> <SearchTerms>Test</SearchTerms> <SearchTerms>Test-ying</SearchTerms> <ItemType>flat-sheets</ItemType> <IsGiftWrapAvailable>false</IsGiftWrapAvailable> <IsGiftMessageAvailable>false</IsGiftMessageAvailable> </DescriptionData> <ProductData> <Home> <Parentage>variation-parent</Parentage> <VariationData> <VariationTheme>Size-Color</VariationTheme> </VariationData> <Material>cotton</Material> <ThreadCount>500</ThreadCount> </Home> </ProductData> </Product> </Message> </AmazonEnvelope>

Get the return <?xml version="1.0" encoding="UTF-8"?> <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.02</DocumentVersion> <MerchantIdentifier>XXXXXXXXX</MerchantIdentifier> </Header> <MessageType>ProcessingReport</MessageType> <Message> <MessageID>1</MessageID> <ProcessingReport> <DocumentTransactionID>XXXXXX</DocumentTransactionID> <StatusCode>Complete</StatusCode> <ProcessingSummary> <MessagesProcessed>0</MessagesProcessed> <MessagesSuccessful>0</MessagesSuccessful> <MessagesWithError>1</MessagesWithError> <MessagesWithWarning>0</MessagesWithWarning> </ProcessingSummary> <Result> <MessageID>0</MessageID> <ResultCode>Error</ResultCode> <ResultMessageCode>5001</ResultMessageCode> <ResultDescription>XML Parsing Fatal Error at Line 1, Column 226: The element type &quot;Header&quot; must be terminated by the matching end-tag &quot;&lt;/Header&gt;&quot;. The element type &quot;Header&quot; must be terminated by the matching end-tag &quot;&lt;/Header&gt;&quot;.</ResultDescription> </Result> </ProcessingReport> </Message> </AmazonEnvelope>

marketplacehub-com commented 3 years ago

I can`t say something about XML, since I using CSV files. After uploading encrypted CSV file (I also using PUT Http request type for that) - I getting empty response and this is fine. After that - I do CreateFeed using FeedDocumentId which I got from CreateFeedDocument request.

MrYing commented 3 years ago

@esalesplatform Thanks

github-actions[bot] commented 2 years ago

This is a very old issue that is probably not getting as much attention as it deserves. We encourage you to check if this is still an issue after the latest release and if you find that this is still a problem, please feel free to open a new issue and make a reference to this one.