Amplify Auth with Hosted UI process Stripe OAuth url
See original GitHub issueDescribe the bug In my Angular project, I have configured AWS Amplify with OAuth and Hosted UI.
Everything is working fine. When I want to connect with Google, I am redirected back with an url like http://localhost:4200/?code=de79bfa4-xxxxxx&state=2xxxxxx which is well handled by the AWS Amplify Hub.
Now, I want to configure Stripe Connect in my project which also use an OAuth connection flow.
So I configure my OAuth link as defined in the documentation by adding a link as below:
<a class="stripe-connect" href="https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_xxxxxx&scope=read_write"><span>Connect with Stripe</span></a>
Problem I am redirected back with an url like http://localhost:4200/stripe?scope=read_write&code=ac_xxxxxx
Unfortunately, this url is also processed by Amplify and I got the following error message :
zone.js:1152 POST https://[domain].amazoncognito.com/oauth2/token 400 core.js:15724 ERROR Error: Uncaught (in promise): Error: invalid_grant Error: invalid_grant
To Reproduce Steps to reproduce the behavior:
- Configure the sample repository with Amplify Auth Hosted UI
- Edit the Stripe client_id in
stripe.component.html
- Start the project
- Connect with google
- Navigate to Settings
- Click on the link ‘Connect with Stripe’
- On the Stripe form, click ‘Ignore this account form’
- See the error
Expected behavior Amplify do not proceed the Stripe url
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: MacOS Mojave v 10.14.4
- Browser Chrome
- Version 73.0.3683.103
Additional context N/A
Sample code Sample repo available : https://github.com/JohanRin/sample-amplify-stripe.git
You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = ‘DEBUG’; in your app.
Failed to load resource: the server responded with a status of 400 () ConsoleLogger.js:88 [DEBUG] 11:58.755 AuthClass - Error in cognito hosted auth response Error: invalid_grant at OAuth.<anonymous> (OAuth.js:143) at step (OAuth.js:52) at Object.next (OAuth.js:33) at fulfilled (OAuth.js:24) at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391) at Object.onInvoke (core.js:17299) at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:390) at Zone.push…/node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150) at zone.js:889 at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423) ConsoleLogger.js:88 [DEBUG] 11:58.756 Hub - Dispatching to auth with Object ConsoleLogger.js:88 [DEBUG] 11:58.756 Hub - Dispatching to auth with Object ConsoleLogger.js:88 [DEBUG] 11:58.756 Hub - Dispatching to auth with Object ConsoleLogger.js:88 [DEBUG] 11:58.756 Hub - Dispatching to auth with Object
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (5 by maintainers)
Top GitHub Comments
Thanks everyone for the research! Indeed, authenticating with Stripe via Cognito would be a feature request, but Amplify handling the URL because Stripe also uses
code
seems like a bug:https://github.com/aws-amplify/amplify-js/blob/ab08e38e22801e3a212f299057ecc9670fae5633/packages/auth/src/Auth.ts#L1811-L1823
I’m going to bring this up with the team with the recommendation that we track both sides of the OAuth flow (so that it works for federated sign-in with Google, but ignores Stripe).
Also having this same issue. Would appreciate if this issue is addressed with the next update for aws-amplify