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

Migrating MWS Sellers to SP-API #1239

Closed nrogers805 closed 2 years ago

nrogers805 commented 3 years ago

Why can't I migrate my current MWS sellers to SP-API while the Hybrid App is in 'pending' state?

The MWS version of the App has been live for several years so I should be able to migrate these sellers now!?!?

What's the reason for not allowing the migration?

Getting this error: { "errors": [ { "code": "InvalidInput", "message": "A published application with the provided app-id not found", "details": "" } ] }

rugved1991 commented 3 years ago

Hi @nrogers805,

You can use the Authorization API once the app is published. The draft application allows you to test the new SP APIs before making any changes to your already published MWS application. Once you are comfortable with the testing and have implemented a solution on your client to handle the OAuth flow for new users, you can initiate app publish process.

Thanks, Rugved Solutions Architect, SP API

nrogers805 commented 3 years ago

Hi @rugved1991

Why does my app need to be published to use the SP-API?

We need to be able to test our apps for weeks/months before we allow any new signups using the SP-API authentication

I want to convert my current users over and then replace mws to SP-API on a piece by piece method. I don't want to re-developed the whole app in one go and then hope for the best, that is just insane

This process needs a re-think at Amazon as the current process is unworkable and has not been thought out at all

Thanks

nrogers805 commented 3 years ago

Hi @rugved1991

Could you please respond to my last comment.

Thanks

rugved1991 commented 3 years ago

Hi @nrogers805,

You can test the SP APIs while the app is in the draft status. The hybrid application allows you to test both MWS and SP APIs. We ask you to test the new SP APIs with just one or two sellers first to test out your use cases. You will need to ask these one or two sellers to re-authorize your application for testing purpose. Once you are comfortable with the new APIs, you can publish the app and migrate your users directly. You do not need to ask your existing sellers to reauthorize your application. This provides a better customer experience and allows the developers to pilot the new APIs with few sellers initially.

Thanks, Rugved Solutions Architect, SP API

ulandj commented 3 years ago

Hi @rugved1991,

You can test the SP APIs while the app is in the draft status. The hybrid application allows you to test both MWS and SP APIs. We ask you to test the new SP APIs with just one or two sellers first to test out your use cases.

I have a hybrid SP API application in the dreft status but when I request GET /authorization/v1/authorizationCode the server responds:

{
  errors: [
    {
      code: 'InvalidInput',
      message: 'Developer ID 5xxxxxxxxxxxx0 is not associated with the application id.',
      details: ''
    }
  ]
}

As guys in this issue ticket - https://github.com/amzn/selling-partner-api-models/issues/805 claim that it will be possible only after publishing the hybrid application - https://github.com/amzn/selling-partner-api-models/issues/805 and even @parvathm confirmed that

Can you please try the request now? We have update a configuration now looks like it was missed when publishing the application.

But we would like to test migration customers' mws token to SP API token in a draft status of the hybrid application. And also was suggested to enable “Enable the OAuth from AppStore” option of the hybrid application but I guess it's only available after publishing the hybrid app.

Or we need to re-authorize some of our customers to get authorization code for mws token as you said: You will need to ask these one or two sellers to re-authorize your application for testing purpose. ? Thanks

rugved1991 commented 3 years ago

Hi @ulandj,

You can use the Authorization API once your app is published. The "Enable OAuth from AppStore" option is now enabled for all apps by default. You wont be able to find this option on the app settings going forward. You will need to re-authorize some of your customers by sharing the OAuth URL with the "version=beta" parameter. You will receive the spapi_oauth_code and mws_token in the redirect URL. You can use this information to get access tokens and call the SP API.

Thanks, Rugved Solutions Architect, SP API

PrashantMalaviya commented 3 years ago

@rugved1991 hello sir can you help.. this is my code in python...not geting output...what is wronge!!!!

from aws_requests_auth.aws_auth import AWSRequestsAuth import requests import boto3 from time import sleep header = { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", } d = { "grant_type": "client_credentials", "scope": "sellingpartnerapi::notifications", "refresh_token": xxxx, "client_id":xxxx, "client_secret": xxxx, }

response = requests.post("https://api.amazon.com/auth/o2/token", headers=header, data=d) print(response.status_code) data = response.json() access_token = data['access_token'] print("access_token:-"access_token) ############################################## sleep(2) amw_client = boto3.client( 'sts', aws_access_key_id=xxxx, aws_secret_access_key=xxxx, )

response = amw_client.assume_role( RoleArn='xxxx', RoleSessionName='SellingPartnerAPI' ) AccessKeyId = response['Credentials']['AccessKeyId'] SecretAccessKey = response['Credentials']['SecretAccessKey'] SessionToken = response['Credentials']['SessionToken'] print("AccessKeyId:-",response['Credentials']['AccessKeyId']) print("SecretAccessKey:-",response['Credentials']['SecretAccessKey']) print("SessionToken:-",response['Credentials']['SessionToken']) ############################################################################## sleep(2) auth = AWSRequestsAuth(aws_access_key=AccessKeyId, aws_secret_access_key=SecretAccessKey, aws_token=SessionToken, aws_host='sellingpartnerapi-eu.amazon.com', aws_region='eu-west-1', aws_service='execute-api')

endpoint = 'https://sellingpartnerapi-eu.amazon.com/orders/v0/orders?MarketplaceIds=A21TJRUUN4KGV&CreatedAfter=2021-01-05'

headers = {'x-amz-access-token': access_token}

r = requests.get(endpoint, auth=auth, headers=headers) print(r.status_code) print(r.text) @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ optput is :- 200 access_token:-xxxx

AccessKeyId:- xxxx SecretAccessKey:- xxxx SessionToken:- xxxx 403 { "errors": [ { "message": "Access to requested resource is denied.", "code": "Unauthorized", "details": "" } ] }

rugved1991 commented 3 years ago

Hi @PrashantMalaviya,

Thanks for sharing your code snippet. There are a few things I would check to troubleshoot this issue:

  1. Check the IAM ARN configured on your application.
  2. If it is an IAM User ARN, use User credentials to calculate AWS SigV4 signature.
  3. If it is an IAM Role ARN, call AssumeRole operation to get temporary credentials and then use these temporary credentials to calculate AWS SigV4 signature. Please refer to "Important" section in the developer guide.

I also noticed that the "CreatedAfter" value is not in ISO 8601 format. It should be in this format "2017-01-20T19:49:35Z"

Thanks, Rugved Solutions Architect, SP API

diegocvazquez commented 3 years ago

@PrashantMalaviya Hello there I am facing the same issue regarding the Authorization API the error is: Developer ID 9xxxx7is not associated with the application id.

Our application is a Hybrid approved and published Application, I have created the case ID7011006982 Can you please help us?

thanks for your support

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.