简体   繁体   中英

The OAuth response flow failed

I'm using aws amplify along with react-native-inappbrowser . I enabled Google SSO authentication and it is working fine, but when I added GitHub auth it doesn't work as expected. I added a listener using Hub.listen('auth', async (data) => {...} and the urlOpener in my awsConfig looks like this:

onst urlOpener = async (url, redirectUrl, settings) => {
  try {
    if (await InAppBrowser.isAvailable()) {
      const { type, url: newUrl } = await InAppBrowser.openAuth(
        url,
        redirectUrl,
        { ...inAppBrowserSettings, ...settings },
      );
      if (type === 'success') {
        Linking.openURL(newUrl);
      }
    } else {
      Linking.openURL(url);
    }
  } catch (error) {
    Alert.alert(error.message);
  }
};

The Hub.listener looks like this:

 useEffect(() => {
    const unsubscribe = Hub.listen('auth', async (data) => {
      const { payload } = data;
      const user = payload.data;
      switch (payload.event) {
        case AuthEnum.SIGN_IN:
          handleSignIn(user);
          break;
        case AuthEnum.SIGN_OUT:
          handleSignOut();
          break;
        case AuthEnum.SIGN_IN_FAILURE:
          handleSignInFailure();
          break;
      }

    });
   return () => unsubscribe();
}, []);
    

When I try to authenticate using GitHub, the GitHub API returns the correct token but the aws Hub catches a SIGN_IN_FAILURE and the data looks like this:

{
  "channel": "auth",
  "payload": {
    "event": "signIn_failure",
    "data": {},
    "message": "The OAuth response flow failed"
  },
  "source": "Auth",
  "patternInfo": []
}

I'm not sure why this is happening. A solution could be to remove the listener in case of GitHub auth, but I'm not sure how to do that since the InAppBrowser.openAuth() is used for both the Google SSO and GitHub auth.

Make sure to let me know if the info I provided isn't enough. Any suggestions/help would be great!

I don't think AWS Amplify support github oauth. I believe the supported ones are: Google, Apple, Facebook & Amazon

Supported social logins

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM