question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Amplify Auth with Hosted UI process Stripe OAuth url

See original GitHub issue

Describe 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:

  1. Configure the sample repository with Amplify Auth Hosted UI
  2. Edit the Stripe client_id in stripe.component.html
  3. Start the project
  4. Connect with google
  5. Navigate to Settings
  6. Click on the link ‘Connect with Stripe’
  7. On the Stripe form, click ‘Ignore this account form’
  8. See the error

Expected behavior Amplify do not proceed the Stripe url

Screenshots If applicable, add screenshots to help explain your problem. Capture d’écran 2019-04-24 à 01 07 48

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:closed
  • Created 4 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
ericclemmonscommented, Mar 19, 2020

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).

1reaction
ianvanburencommented, Jan 16, 2020

Also having this same issue. Would appreciate if this issue is addressed with the next update for aws-amplify

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stripe Connect code processed by AWS Amplify Auth
In my Angular project, I have configured AWS Amplify with OAuth and Hosted UI. Everything is working fine. When I want to connect...
Read more >
Using the Amazon Cognito hosted UI for sign-up and sign-in
The Amazon Cognito Hosted UI provides you an OAuth 2.0 compliant authorization server. It includes default implementation of end user flows such as ......
Read more >
Authentication - Social sign-in (OAuth) - JavaScript
Run amplify push to publish your changes. Once finished, it will display an auto generated URL for your web UI. You can retrieve...
Read more >
Implement Authentication in Angular using AWS Amplify -
The @aws-amplify/ui-angular package is a set of Angular components and an Angular provider which helps integrate your application with the AWS- ...
Read more >
Get OAuth 2.0 tokens | Apigee X - Google Cloud
This document shows you how to get OAuth 2.0 access tokens and authorization codes with the Apigee API. We also show how to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found