aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.44k stars 2.13k forks source link

Login with google on Android received the event: parsingCallbackUrl #11737

Closed hoangtam101 closed 1 year ago

hoangtam101 commented 1 year ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

``` # Put output below this line System: Android Version: 11 Device name: Nokia C21 Plus Binaries: Node: v19.5.0 Yarn: 1.22.19 npmPackages: "@apollo/client": "^3.7.15", "@aws-amplify/auth": "^5.3.7", "@miblanchard/react-native-slider": "^2.3.1", "@react-native-async-storage/async-storage": "^1.18.1", "@react-native-clipboard/clipboard": "^1.11.2", "@react-native-community/netinfo": "^9.3.10", "@react-native-firebase/analytics": "14.12.0", "@react-native-firebase/app": "14.12.0", "@react-native-firebase/crashlytics": "14.12.0", "@react-native-firebase/perf": "14.12.0", "@react-native-masked-view/masked-view": "^0.2.8", "@react-navigation/bottom-tabs": "^6.5.7", "@react-navigation/native": "^6.1.6", "@react-navigation/stack": "^6.3.16", "@reduxjs/toolkit": "^1.9.3", "amazon-cognito-identity-js": "^6.2.0", "aws-amplify": "^5.2.0", "aws-amplify-react-native": "^7.0.2", "aws-appsync-auth-link": "^3.0.7", "aws-appsync-subscription-link": "^3.1.2", "chroma-js": "^2.4.2", "i18next": "^22.4.10", "lodash": "^4.17.21", "nanoid": "^4.0.2", "react": "18.2.0", "react-i18next": "^12.2.0", "react-native": "0.71.4", "react-native-bootsplash": "^4.7.1", "react-native-code-push": "^8.0.2", "react-native-collapsible-tab-view": "^6.1.4", "react-native-fast-image": "^8.6.3", "react-native-gesture-handler": "^2.9.0", "react-native-inappbrowser-reborn": "^3.7.0", "react-native-mmkv": "^2.6.2", "react-native-modalize": "^2.1.1", "react-native-pager-view": "^6.2.0", "react-native-portalize": "^1.0.7", "react-native-progress": "^5.0.0", "react-native-reanimated": "^3.0.2", "react-native-safe-area-context": "^4.5.0", "react-native-screens": "^3.20.0", "react-native-shadow-2": "^7.0.8", "react-native-share": "^8.2.2", "react-native-simple-toast": "1.1.4", "react-native-sticky-parallax-header": "^1.1.1", "react-native-svg": "^13.9.0", "react-native-tts": "^4.1.0", "react-native-version-check": "3.4.7", "react-native-video": "^5.2.1", "react-redux": "^8.0.5", "redux-persist": "^6.0.0" "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native-community/eslint-config": "^3.2.0", "@react-navigation/devtools": "^6.0.18", "@testing-library/jest-native": "^5.4.2", "@testing-library/react-native": "^12.0.0", "@tsconfig/react-native": "^2.0.2", "@types/jest": "^29.4.0", "@types/lodash": "^4.14.195", "@types/node": "^18.14.1", "@types/react": "^18.0.24", "@types/react-native-video": "^5.0.13", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.2.1", "babel-plugin-inline-dotenv": "^1.7.0", "babel-plugin-module-resolver": "^5.0.0", "babel-plugin-root-import": "^6.6.0", "dotenv": "^16.0.3", "eslint": "^8.19.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "0.73.8", "prettier": "^2.4.1", "react-native-flipper": "^0.182.0", "react-test-renderer": "18.2.0", "redux-flipper": "^2.0.2", "typescript": "4.8.4" ```

Describe the bug

Bug is related to android platform which is happening only when doing login using Auth.federatedSignIn(provider: 'Google') When I call the login by google then open the webview and then I received the data below

{"channel":"auth","payload":{"event":"parsingCallbackUrl","data":{"url":null},"message":"The callback url is being parsed"},"source":"Auth","patternInfo":[]}

Expected behavior

Receive the correct data to handle it.

Reproduction steps

  1. Run the app with android studio into the android device
  2. Click on button which will trigger the Auth.federatedSignIn(provider: 'Google') and see the behaviour
  3. The web view will be presenter
  4. Choose the account want to login
  5. Then data will be log and nothing happen

Code Snippet

// Put your code below this line.
Hub.listen('auth', async data => {
    console.log(JSON.stringify(data));
    switch (data.payload.event) {
      case 'codeFlow':
        dispatch(
          updateSignUpModal({
            showModal: false,
          }),
        );
        if (getRouteName() !== 'HomeMain') {
          setLoading(true);
        }
        dispatch(resetData('codeFlow'));
        break;
      case 'signIn':
        await checkUser(true);
        setLoading(false);
        break;
      case 'signOut':
        break;
      case 'oAuthSignOut':
        break;
      default:
        break;
    }
  });

  Auth.federatedSignIn({
      provider: CognitoHostedUIIdentityProvider.Apple,
    });

Log output

``` // Put your logs below this line {"channel":"auth","payload":{"event":"parsingCallbackUrl","data":{"url":null},"message":"The callback url is being parsed"},"source":"Auth","patternInfo":[]} ```

aws-exports.js

const awsmobile = {
  aws_project_region: 'us-east-1',
  aws_cognito_identity_pool_id:
    'us-east-1:pool_id',
  aws_cognito_region: 'us-east-1',
  aws_user_pools_id: 'pool_id',
  aws_user_pools_web_client_id: 'client_id',
  oauth: {
    domain:
      'xyz-dev.auth.us-east-1.amazoncognito.com',
    scope: [
      'phone',
      'email',
      'openid',
      'profile',
      'aws.cognito.signin.user.admin',
    ],
    redirectSignIn: 'demoapp://',
    redirectSignOut: 'demoapp://',
    responseType: 'code',
    urlOpener: null,
  },
  predictions: {
    convert: {
      speechGenerator: {
        region: "us-east-1",
        proxy: false,
        defaults: {
          VoiceId: "Salli",
          LanguageCode: "en-US"
        }
      }
    }
  },
  federationTarget: 'COGNITO_USER_POOLS',
  aws_cognito_username_attributes: [],
  aws_cognito_social_providers: ['GOOGLE', 'APPLE'],
  aws_cognito_signup_attributes: ['EMAIL'],
  aws_cognito_mfa_configuration: 'OFF',
  aws_cognito_mfa_types: ['SMS'],
  aws_cognito_password_protection_settings: {
    passwordPolicyMinLength: 8,
    passwordPolicyCharacters: [],
  },
  aws_cognito_verification_mechanisms: ['EMAIL'],
  aws_appsync_graphqlEndpoint:
    'https://xyz.appsync-api.us-east-1.amazonaws.com/graphql',
  aws_appsync_region: 'us-east-1',
  aws_appsync_authenticationType: 'AMAZON_COGNITO_USER_POOLS',
  aws_appsync_apiKey: 'appsync_key',
  aws_content_delivery_bucket: 'xyz-hostingbucket-dev',
  aws_content_delivery_bucket_region: 'us-east-1',
  aws_content_delivery_url: 'https://xyz.cloudfront.net',
}

Manual configuration

No response

Additional configuration

No response

Mobile Device

Android

Mobile Operating System

11

Mobile Browser

Using react-native-inappbrowser-reborn

Mobile Browser Version

3.7.0

Additional information and screenshots

No response

hoangtam101 commented 1 year ago

I've fixed this issues Thanks,

cwomack commented 1 year ago

@hoangtam101, glad to hear you were able to unblock yourself before we could investigate this further. Can you share what the fix was or what you did to resolve it? Always love to see if we can get that context in the event someone searches for something similar within our repo looking for an answer.

Also, is there any improvements to the documentation that you'd recommend to help avoid running into this again? Appreciate any feedback you'd be willing to give.

hoangtam101 commented 1 year ago

Yes, I've wrong when input the <intent-filter> inside SplashActivity It should be inside MainActivity

Regards,

hoangtam101 commented 1 year ago

Sorry @cwomack , I've opened the issue because sometimes I can not log in with Google on Android device.

I got the error message below.

 LOG  {"channel":"auth","payload":{"event":"signIn_failure","data":{},"message":"The OAuth response flow failed"},"source":"Auth","patternInfo":[]}
 LOG  {"channel":"auth","payload":{"event":"cognitoHostedUI_failure","data":{},"message":"A failure occurred when returning to the Cognito Hosted UI"},"source":"Auth","patternInfo":[]}
 LOG  {"channel":"auth","payload":{"event":"customState_failure","data":{},"message":"A failure occurred when returning state"},"source":"Auth","patternInfo":[]}
 LOG  {"channel":"auth","payload":{"event":"signIn_failure","data":{},"message":"The OAuth response flow failed"},"source":"Auth","patternInfo":[]}
 LOG  {"channel":"auth","payload":{"event":"cognitoHostedUI_failure","data":{},"message":"A failure occurred when returning to the Cognito Hosted UI"},"source":"Auth","patternInfo":[]}
 LOG  {"channel":"auth","payload":{"event":"customState_failure","data":{},"message":"A failure occurred when returning state"},"source":"Auth","patternInfo":[]}

System: Android Version: 10 Device name: Samsung Galaxy S9

Thanks and regards,

cwomack commented 1 year ago

@hoangtam101, do you get the error when trying to login again a second time? Also, do you see the failure happen on Android emulators or real/physical devices (or both)?

cwomack commented 1 year ago

Closing this issue as we have not heard back from you. If you are still experiencing this, please feel free to reply back and provide any information previously requested and we'd be happy to re-open the issue.

Thank you!