amplify-js: Federated sign-in: [TypeError: Cannot read property 'oauthSignIn' of undefined]

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

# Put output below this line


  System:
    OS: macOS 13.3.1
    CPU: (8) arm64 Apple M1
    Memory: 96.27 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.19.1 - ~/.nvm/versions/node/v16.19.1/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.3 - ~/.nvm/versions/node/v16.19.1/bin/npm
    Watchman: 2023.04.24.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 112.0.5615.137
    Safari: 16.4
  npmPackages:
    @babel/core: ^7.20.0 => 7.21.3 (7.21.4)
    @babel/plugin-proposal-decorators: 7.20. => 7.21.0
    @babel/plugin-proposal-optional-catch-binding: 7.16.7 => 7.16.7 (7.18.6)
    @babel/preset-env: ^7.20.0 => 7.20.2
    @babel/runtime: ^7.20.0 => 7.21.0
    @expo-google-fonts/space-grotesk: ^0.2.2 => 0.2.3
    @expo/webpack-config: ^18.0.1 => 18.0.2
    @react-native-async-storage/async-storage: ^1.18.1 => 1.18.1
    @react-native-community/cli-platform-ios: ^8.0.2 => 8.0.6 (10.2.1)
    @react-native-community/eslint-config: ^3.2.0 => 3.2.0
    @react-native-community/netinfo: ^9.3.9 => 9.3.9
    @react-native-firebase/analytics: ^17.3.1 => 17.4.0
    @react-native-firebase/app: ^17.3.1 => 17.4.0
    @react-navigation/bottom-tabs: ^6.3.2 => 6.5.7
    @react-navigation/native: ~6.0.1 => 6.0.16
    @react-navigation/native-stack: ^6.0.2 => 6.9.12
    @react-navigation/stack: ~6.2.1 => 6.2.3
    @sentry/react-native: ^5.2.0 => 5.2.0
    @tsconfig/react-native: ^2.0.2 => 2.0.3
    @types/i18n-js: 3.8.2 => 3.8.2
    @types/jest: ^29.2.1 => 29.5.0
    @types/react: ^18.0.24 => 18.0.31 (17.0.55)
    @types/react-native: 0.67.8 => 0.67.8
    @types/react-test-renderer: ^18.0.0 => 18.0.0
    @typescript-eslint/eslint-plugin: 5.28.0 => 5.28.0 (5.57.0)
    @typescript-eslint/parser: 5.28.0 => 5.28.0 (5.57.0)
    ContextAPIMixpanel:  0.0.1
    HelloWorld:  0.0.1
    MixpanelDemo:  0.0.1
    SimpleMixpanel:  0.0.1
    TypingIndicatorExample:  0.0.1
    amazon-cognito-identity-js: ^6.2.0 => 6.2.0
    apisauce: 2.1.5 => 2.1.5
    appcenter: 4.4.5 => 4.4.5
    appcenter-analytics: 4.4.5 => 4.4.5
    appcenter-crashes: 4.4.5 => 4.4.5
    aws-amplify: ^5.1.3 => 5.1.3
    aws-amplify-react-native: ^7.0.2 => 7.0.2
    aws-api-gateway-client: ^0.3.7 => 0.3.7
    aws-sdk: ^2.1328.0 => 2.1345.0
    axios: ^1.3.4 => 1.3.4 (0.26.0, 0.21.4, 0.19.0-beta.1)
    babel-jest: ^29.2.1 => 29.5.0 (26.6.3)
    babel-loader: 8.2.5 => 8.2.5 (8.3.0)
    core-js: ^3.30.1 => 3.30.1 (2.6.12)
    date-fns: ^2.29.2 => 2.29.3
    detox: 19.12.1 => 19.12.1
    detox-expo-helpers: 0.6.0 => 0.6.0
    eslint: ^8.19.0 => 8.37.0
    eslint-config-prettier: 8.5.0 => 8.5.0 (8.8.0)
    eslint-config-standard: 17.0.0 => 17.0.0
    eslint-plugin-import: 2.26.0 => 2.26.0
    eslint-plugin-n: ^15.0.0 => 15.6.1
    eslint-plugin-node: 11.1.0 => 11.1.0
    eslint-plugin-promise: 6.0.0 => 6.0.0
    eslint-plugin-react: 7.30.0 => 7.30.0 (7.32.2)
    eslint-plugin-react-native: 4.0.0 => 4.0.0
    expo: ^48.0.0 => 48.0.9
    expo-application: ~5.1.1 => 5.1.1
    expo-av: ^13.2.1 => 13.2.1
    expo-constants: ~14.2.1 => 14.2.1
    expo-detox-hook: 1.0.10 => 1.0.10
    expo-device: ~5.2.1 => 5.2.1
    expo-file-system: ~15.2.2 => 15.2.2
    expo-font: ~11.1.1 => 11.1.1
    expo-linear-gradient: ~12.1.2 => 12.1.2
    expo-linking: ~4.0.1 => 4.0.1
    expo-localization: ~14.1.1 => 14.1.1
    expo-modules-autolinking: ~1.1.0 => 1.1.2
    expo-modules-core: ~1.2.6 => 1.2.6
    expo-notifications: ^0.18.1 => 0.18.1
    expo-permissions: ^14.1.1 => 14.1.1
    expo-splash-screen: ~0.18.1 => 0.18.1
    expo-status-bar: ~1.4.2 => 1.4.4
    expo-web-browser: ~12.1.1 => 12.1.1
    fbjs-scripts: 3.0.1 => 3.0.1
    firebase: ^9.17.1 => 9.18.0
    firebase/analytics:  undefined ()
    firebase/app:  undefined ()
    firebase/app-check:  undefined ()
    firebase/auth:  undefined ()
    firebase/auth/cordova:  undefined ()
    firebase/auth/react-native:  undefined ()
    firebase/compat:  undefined ()
    firebase/compat/analytics:  undefined ()
    firebase/compat/app:  undefined ()
    firebase/compat/app-check:  undefined ()
    firebase/compat/auth:  undefined ()
    firebase/compat/database:  undefined ()
    firebase/compat/firestore:  undefined ()
    firebase/compat/functions:  undefined ()
    firebase/compat/installations:  undefined ()
    firebase/compat/messaging:  undefined ()
    firebase/compat/performance:  undefined ()
    firebase/compat/remote-config:  undefined ()
    firebase/compat/storage:  undefined ()
    firebase/database:  undefined ()
    firebase/firestore:  undefined ()
    firebase/firestore/lite:  undefined ()
    firebase/functions:  undefined ()
    firebase/installations:  undefined ()
    firebase/messaging:  undefined ()
    firebase/messaging/sw:  undefined ()
    firebase/performance:  undefined ()
    firebase/remote-config:  undefined ()
    firebase/storage:  undefined ()
    i18n-js: 3.9.2 => 3.9.2
    jest: ^29.2.1 => 29.5.0
    jest-circus: 26 => 26.6.3 (29.5.0)
    jest-environment-node: 26 => 26.6.2 (29.5.0)
    jest-expo: ^47.0.0 => 47.0.1
    lodash: ^4.17.21 => 4.17.21
    metro-react-native-babel-preset: 0.73.9 => 0.73.9 (0.73.8)
    mixpanel-react-native: ^2.2.1 => 2.2.1
    mobx: 6.6.0 => 6.6.0
    mobx-react-lite: 3.4.0 => 3.4.0
    mobx-state-tree: 5.1.5 => 5.1.5
    mocha: 6 => 6.2.3
    patch-package: 6.4.7 => 6.4.7
    postinstall-prepare: 1.0.1 => 1.0.1
    prettier: ^2.4.1 => 2.8.7
    query-string: ^8.1.0 => 8.1.0 (7.1.3, 5.1.1, 6.10.1)
    react: 18.2.0 => 18.2.0 (16.14.0)
    react-devtools-core: 4.24.7 => 4.24.7 (4.27.4)
    react-dom: 18.2.0 => 18.2.0
    react-hook-form: ^7.43.2 => 7.43.8
    react-native: 0.71.7 => 0.71.7
    react-native-bootsplash: ^4.6.0 => 4.6.0
    react-native-canvas: ^0.1.38 => 0.1.38
    react-native-code-push: ^8.0.0 => 8.0.0
    react-native-config: 1.4.12 => 1.4.12
    react-native-gesture-handler: ~2.9.0 => 2.9.0
    react-native-get-random-values: ^1.8.0 => 1.8.0
    react-native-gifted-chat: ^2.0.1 => 2.0.1
    react-native-keyboard-aware-scroll-view: ^0.9.5 => 0.9.5
    react-native-keychain: ^8.1.1 => 8.1.1
    react-native-reanimated: ~2.14.4 => 2.14.4
    react-native-reanimated-carousel: ^3.3.0 => 3.3.0
    react-native-redash: 14.0.4 => 14.0.4
    react-native-render-html: ^6.3.4 => 6.3.4
    react-native-safe-area-context: 4.5.0 => 4.5.0
    react-native-screens: ~3.20.0 => 3.20.0
    react-native-svg: ^13.9.0 => 13.9.0
    react-native-svg-transformer: ^1.0.0 => 1.0.0
    react-native-typing-animation: ^0.1.7 => 0.1.7
    react-native-web: ^0.18.7 => 0.18.12
    react-native-webview: 11.26.0 => 11.26.0
    reactotron-core-client: ^2.8.10 => 2.8.10 (2.8.9)
    reactotron-mst: 3.1.4 => 3.1.4
    reactotron-react-js: ^3.3.7 => 3.3.8
    reactotron-react-native: 5.0.3 => 5.0.3
    regenerator-runtime: ^0.13.4 => 0.13.11 (0.11.1)
    ts-jest: 26 => 26.5.6
    typescript: ^4.9.4 => 4.9.5
    webpack: 4 => 4.46.0 (5.76.3)
    webpack-dev-server: ^3 => 3.11.3 (4.13.1)
  npmGlobalPackages:
    @aws-amplify/cli: 10.8.1
    appcenter-cli: 2.13.6
    aws-sdk: 2.1334.0
    corepack: 0.15.1
    expo-cli: 6.3.2
    npm: 8.19.3
    serverless: 3.28.1

Describe the bug

I’m doing a release build on Android for React Native, and I’m trying to do federated sign in with Google, like so:

Auth.federatedSignIn({
          provider: CognitoHostedUIIdentityProvider.Google
})

When I do this, I get [TypeError: Cannot read property 'oauthSignIn' of undefined]

Expected behavior

It should launch the oAuth screen for Google, instead nothing happens.

Reproduction steps

const MyApp = () => {

const signIn = async () => {
    await Auth.federatedSignIn({
          provider: CognitoHostedUIIdentityProvider.Google
      })
}

return <Button text="Sign in with Google" onPress={signIn} />
}

Code Snippet

No response

Log output

No response

aws-exports.js

/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = {
    "aws_project_region": "ap-southeast-2",
    "aws_cognito_identity_pool_id": "ap-southeast-2:xxxxxx",
    "aws_cognito_region": "ap-southeast-2",
    "aws_user_pools_id": "ap-southeast-2_xxxxxx",
    "aws_user_pools_web_client_id": "xxxxxx",
    "oauth": {
        "domain": "xxxxxx.auth.ap-southeast-2.amazoncognito.com",
        "scope": [
            "phone",
            "email",
            "openid",
            "profile",
            "aws.cognito.signin.user.admin"
        ],
        "redirectSignIn": "com.myapp.name://",
        "redirectSignOut": "com.myapp.name://",
        "responseType": "code"
    },
    "federationTarget": "COGNITO_USER_POOLS",
    "aws_cognito_username_attributes": [
        "EMAIL"
    ],
    "aws_cognito_social_providers": [
        "FACEBOOK",
        "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"
    ]
};


export default awsmobile;


Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 32 (13 by maintainers)

Most upvoted comments

We’re also experiencing the same issue, any updates?

@jvgeee I just ran into this error and have a suggestion. If you are using config vars or environment secrets of some kind to specify the redirect URL (to override multiple entries as we are told to), take a look and see if it is specified correctly for your release build setup. If it is not, it would cause precisely this error to occur in only your release builds.

In my case it was the opposite, my dev build suddenly stopped working with this error. Turned out my .env file was not being picked up by expo, as I had earlier run the app without the .env and the cache never looked for a new one.

Just rebuilt the app on top of a fresh Ignite release, try pulling it and then try npx react-native run-ios --mode Release.

@nadetastic Yep sure, I’ve made a duplicate repo and added you as a contributor. Repo will have to be private though, that ok?

The original boilerplate for this app was using Ignite: https://github.com/infinitered/ignite

Dunno if you’ll have trouble doing builds as the XCode profiles are set to my account. Android might be easier (this is a cross-platform issue, so debug builds work on both Android and IOS and release builds fail)

Look for the SocialSignIn component, as well as the user.authSocialSignIn in ./app/models/User.ts.

@nadetastic No. I’ve deleted the amplify folder, run amplify pull, and the same issue happens. When I run a debug build of the app on IOS, federated sign in with Google works. When I run a release build on IOS (change schema build configuration from debug to release) it fails.

Have tried a bunch of variations and still can’t get it to work. Any ideas?

image

@nadetastic we filled in our oauth object ourselves as all things we tried (including these steps you proposed didn’t work). Now when we update the amplify auth, aws-export is being updated. Thanks, this fixed this issue. The error message however is not clear what the root cause of this is.

This is not only an issue for React Native. We’re also experiencing this using plain React (in NextJS).