amplify-js: Federated Sign In (Google) with Cognito is not working on Android and Expo Standalone
Describe the bug I’m using withOAuth() HOC. User is directed to the Google (code) flow, comes back to the app. Linking url event is triggered (with code parameter in the url) thus causing a call to Amplify token endpoint (with code_verifier). However, multiple additional Linking url events are fired, causing a throttle of token endpoint calls to trigger (all of them without code_verifier) that ends up with invalid_request and invalid_grant and eventually crashes the app. This happens only on Android (iOS works fine) and in Expo standalone (for some reason, when running the app in the Expo Client, it works fine because the url is stripped from the code this the token endpoint is not called).
To Reproduce Steps to reproduce the behavior: User Expo standalone Android app with Amplify withOAuth HOC to call google.
Expected behavior Avoid invalid calls to the token endpoint.
Smartphone (please complete the following information):
- Device: Any Android device
- OS: Any Android version
- Expo Standalone
Here is the relevant config of Auth.configure:
const urlOpener = async (url, redirectUrl) => {
const { type, url: newUrl } = await WebBrowser.openAuthSessionAsync(
url,
redirectUrl
);
if (Platform.OS === 'ios') {
if (type === 'success') {
await WebBrowser.dismissBrowser();
return Linking.openURL(newUrl);
}
}
};
export const oauth = {
domain: 'some.domain.com',
scope: [
'phone',
'email',
'openid',
'profile',
'aws.cognito.signin.user.admin'
],
redirectSignIn: Linking.makeUrl('/signIn'),
redirectSignOut: Linking.makeUrl('/signOut'),
responseType: 'code',
urlOpener: urlOpener
};
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 17 (2 by maintainers)
I have this issue as well on standalone Android builds, generated using Expo. I can see the error when connecting to a debugger (shows up a couple times before the app crashes):
I’ve opened a PR #4005