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
612 stars 736 forks source link

Website Authorization "Confirm" button does not work #1470

Closed norberttech closed 2 years ago

norberttech commented 3 years ago

Hey so I'm trying to test Website Authorization Workflow. I was able to successfully generate OAuth URL, I'm using &version=beta flat to test my app in draft mode and when my app redirects me to Amazon I'm unable to click "Confirm" button. It looks that the button is broken due to JS errors. Screenshot attached

image

1.2931a0e….min.js:2 Uncaught TypeError: Cannot read property 'endsWith' of undefined
    at Object.t.buildUrl (main.02cdb77….min.js:1)
    at t.handleRedirect (main.02cdb77….min.js:1)
    at Object.s (1.2931a0e….min.js:2)
    at h (1.2931a0e….min.js:2)
    at 1.2931a0e….min.js:2
    at b (1.2931a0e….min.js:2)
    at ae (1.2931a0e….min.js:2)
    at ie (1.2931a0e….min.js:2)
    at se (1.2931a0e….min.js:2)
    at he (1.2931a0e….min.js:2)
t.buildUrl  @   main.02cdb77….min.js:1
t.handleRedirect    @   main.02cdb77….min.js:1
s   @   1.2931a0e….min.js:2
h   @   1.2931a0e….min.js:2
(anonymous) @   1.2931a0e….min.js:2
b   @   1.2931a0e….min.js:2
ae  @   1.2931a0e….min.js:2
ie  @   1.2931a0e….min.js:2
se  @   1.2931a0e….min.js:2
he  @   1.2931a0e….min.js:2
M   @   1.2931a0e….min.js:2
z   @   1.2931a0e….min.js:2
Je  @   1.2931a0e….min.js:2
Xe  @   1.2931a0e….min.js:2
e.unstable_runWithPriority  @   1.2931a0e….min.js:2
qi  @   1.2931a0e….min.js:2
N   @   1.2931a0e….min.js:2
Ge  @   1.2931a0e….min.js:2

Is there any other way to test this process?

LukeLim81 commented 3 years ago

I'm getting the same error as well. I am also using &version=beta.

ShivikaK commented 3 years ago

Hello @norberttech

Thank you for raising this issue.

Can you share the OAuth authorization URL being created for this test so we can reproduce the issue on our end?

Thanks, Shivika Khare Selling Partner API Developer Support

norberttech commented 3 years ago

Hey please find website authorization workflow url for my app below:

https://sellercentral.amazon.com/apps/authorize/consent?application_id=amzn1.sp.solution.d609e727-b917-47ef-ab76-d461178f3a50&redirect_uri=%2Fapprove&state=invalid_state&version=beta

My app will reject redirect from amazon due to invalid_state but I never managed to get that far because of the "Confirm" button JavaScript error.

LukeLim81 commented 3 years ago

In the page where we define the redirect URL, there is also another field above that. When I left the field above blank, I get this error. But once I put in a URL for it (just a website URL), I managed to get the Confirm button working.

norberttech commented 3 years ago

@LukeLim81 the second URL is there for Marketplace Authorization Workflow, which is not always something you want/need.

wkrsz commented 3 years ago

@ShivikaK were you able to reproduce this?

I'm having exact same issue. Getting a nice access request page, but confirm button does nothing, only "Cannot read property 'endsWith' of undefined" appears in browser's developer console.

Our callback URI does not receive any requests.

The auth URL is: https://sellercentral.amazon.com/apps/authorize/consent?application_id=amzn1.sp.solution.d75463db-553d-4beb-91ce-7d945fedec55&version=beta&redirect_uri=https%3A%2F%2Fapp.getdropstream.com%2Fauth%2Famazon%2Fcallback&state=12345

norberttech commented 3 years ago

@wkrsz providing both URLs as suggested by @LukeLim81 solves the problem

image

Also with both URLs Authorization API that is allowing to exchange MWS Token for SP API LWA Code works as expected without throwing any errors about missing OAuth configuration. Maybe both fields are actually mandatory but the form validation is invalid?

wkrsz commented 3 years ago

Yup. That was it. Thanks @norberttech @LukeLim81 – that saved me some gray hair.

CleanShot 2021-06-28 at 13 15 59@2x
ShivikaK commented 3 years ago

Hello everyone,

As stated in the thread, it is required to have both OAuth Login and redirect URI information added to the app for the Confirm button to work correctly.

If the issue persists even after updating this information, please let me know.

Thanks, Shivika Khare Selling Partner API Developer 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.