handleCodeFlow is executed twice
See original GitHub issueDescribe the bug
It seems handleCodeFlow
is executed twice: one succeeds because it can access the PKCE
code, and the second one fails as it does not have a code_verifier
attribute. The second one kicks off a cascade of errors stemming from either invalid_request
or invalid_grant
. Sometimes this leads to authentication failure, even though the response from the hosted UI was successful.
Authentication fails sporadically even though my hosted UI flow was successful, and even though my code could be redeemed successfully.
To Reproduce Running on: “aws-amplify”: “^1.1.29”, “aws-amplify-react-native”: “^2.1.9”,
Steps to reproduce the behavior:
- use Expo 33 (ejected) with RN 59.8
- use hosted UI w/Cognito as the provider
- configure
oauth
with the expourlOpener
- register for hub events in a login component
- sign in and observe two “Calling token endpoint” debug messages
- one will have a code_verifier attribute and one won’t
- sporadic authentication failure (keep retrying and it’ll happen eventually)
The subsequent request that fails will bounce between invalid_grant
and invalid_request
. It alternates, and I can’t seem to spot a pattern that explains why auth fails when it does vs. when it passes.
Expected behavior
I would expect only a single login event, and the handleCodeFlow
code to only run once so that there’s no conflict between what can consume the PKCE
value.
Screenshots If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
- Device: iPhone XR (simulator)
- OS: iOS 12
Additional context
Note: this implements a change to _handleCodeFlow
to address the bug in #3247 – the only change that’s made is to replace the body: body
part of the fetch. The issue is as described in this comment, too.
Seems like it may be related to #3183
Sample code Include additional sample code or a sample repository to help us reproduce the issue. (Be sure to remove any sensitive data)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:14
Top GitHub Comments
Hi there, I am using amplify on the web with react and I am experiencing this issue. So this issue is not only with react native. The amplify team needs to fix this.
@alexofob I had the same issue with event triggered twice on web, because I had
.configure
executed twice in the code - so it assigned urlListener event twice. In my case it wasAmplify.configure({ Auth: ... })
andAuth.configure({ ... })
in another part.