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.43k stars 2.12k forks source link

Auth.federatedSignIn() throws error in iOS 14.5 ... "Provided scheme is not valid" #8446

Closed zacharywenner closed 3 years ago

zacharywenner commented 3 years ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication, Analytics, GraphQL API, Storage, Push Notifications, PubSub

Amplify Categories

auth, storage, function, api, analytics, notifications

Environment information

``` # Put output below this line System: OS: macOS 11.4 CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz Memory: 177.86 MB / 32.00 GB Shell: 5.0.17 - /usr/local/Cellar/bash/5.0.17/bin/bash Binaries: Node: 14.5.0 - ~/.nvm/versions/node/v14.5.0/bin/node Yarn: 1.19.2 - /usr/local/bin/yarn npm: 6.14.6 - ~/.nvm/versions/node/v14.5.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Browsers: Chrome: 91.0.4472.101 Firefox: 81.0.2 Safari: 14.1.1 npmPackages: @aws-amplify/pushnotification: ^3.2.31 => 3.2.31 @babel/core: ^7.8.4 => 7.11.6 (7.10.5) @babel/plugin-proposal-decorators: ^7.7.0 => 7.10.5 @babel/runtime: ^7.8.4 => 7.11.2 (7.10.5) @react-native-community/cli-platform-ios: ^4.0.0 => 4.13.0 @react-native-community/datetimepicker: ^3.5.0 => 3.5.0 @react-native-community/eslint-config: ^1.1.0 => 1.1.0 @react-native-community/masked-view: ^0.1.10 => 0.1.10 @react-native-community/netinfo: ^4.0.0 => 4.7.0 @react-native-community/push-notification-ios: ^1.8.0 => 1.8.0 (1.0.3) @react-native-community/slider: ^3.0.0 => 3.0.3 @react-navigation/bottom-tabs: ^5.11.7 => 5.11.7 @react-navigation/native: ^5.9.2 => 5.9.2 (3.8.3) @react-navigation/stack: ^5.14.2 => 5.14.2 @unimodules/core: ^5.0.0 => 5.5.1 (5.1.2) @unimodules/react-native-adapter: ^5.2.0 => 5.6.0 (5.2.0) amazon-cognito-identity-js: ^4.3.3 => 4.5.7 (4.6.1) apollo-client: ^2.6.4 => 2.6.10 (2.4.6) appcenter: 4.1.0 => 4.1.0 appcenter-analytics: 4.1.0 => 4.1.0 appcenter-crashes: 4.1.0 => 4.1.0 aws-amplify: ^3.4.0 => 3.4.0 aws-amplify-react-native: ^4.3.1 => 4.3.1 aws-appsync: ~3.0.2 => 3.0.4 aws-appsync-auth-link: ^2.0.1 => 2.0.3 (2.0.2) aws-appsync-react: ~3.0.2 => 3.0.4 babel-eslint: ^10.0.3 => 10.1.0 babel-jest: ^25.1.0 => 25.5.1 babel-plugin-transform-remove-console: ^6.9.4 => 6.9.4 babel-preset-expo: ^8.0.0 => 8.3.0 code-push: ^3.1.3 => 3.1.5 css-loader: ^3.0.0 => 3.6.0 eslint: ^6.6.0 => 6.8.0 eslint-config-airbnb: ^18.0.1 => 18.2.0 eslint-plugin-import: ^2.18.0 => 2.22.1 eslint-plugin-jsx-a11y: ^6.2.3 => 6.3.1 eslint-plugin-react: ^7.14.2 => 7.21.3 (7.19.0) eslint-plugin-react-hooks: ^2.1.2 => 2.5.1 (3.0.0) eslint-plugin-react-native: ^3.7.0 => 3.10.0 (3.8.1) expo-facebook: ^8.2.1 => 8.2.1 expo-google-app-auth: ^8.1.2 => 8.1.3 expo-google-sign-in: ^8.2.1 => 8.3.0 graphql: ^14.4.2 => 14.7.0 (14.0.0, 0.13.0) graphql-tag: ^2.10.1 => 2.11.0 hermes-inspector-msggen: 1.0.0 jest: ^25.1.0 => 25.5.4 jetifier: ^1.6.4 => 1.6.6 lodash: ^4.17.15 => 4.17.20 (4.17.19) lottie-ios: 3.1.8 => 3.1.8 lottie-react-native: ^4.0.2 => 4.0.2 memo-parser: 0.2.1 metro-react-native-babel-preset: ^0.59.0 => 0.59.0 (0.58.0) prop-types: ^15.7.2 => 15.7.2 qs: ^6.8.0 => 6.9.4 (6.5.2) react: 16.13.1 => 16.13.1 react-animated: 0.1.0 react-apollo: 2.5.8 => 2.5.8 react-dom: ^16.9.0 => 16.13.1 react-native: 0.63.3 => 0.63.3 react-native-clean-project: ^3.6.4 => 3.6.4 react-native-code-push: ^6.2.1 => 6.3.0 react-native-device-info: ^8.1.3 => 8.1.3 react-native-fast-image: ^8.1.5 => 8.3.2 react-native-fix-image: ^2.1.0 => 2.1.0 react-native-gesture-handler: ^1.9.0 => 1.9.0 react-native-htmlview: ^0.15.0 => 0.15.0 react-native-inappbrowser-reborn: ^3.4.0 => 3.4.0 react-native-linear-gradient: ^2.5.6 => 2.5.6 react-native-material-menu: ^1.0.0 => 1.1.3 react-native-modalize: ^1.2.1 => 1.3.6 react-native-push-notification: ^7.3.1 => 7.3.1 react-native-reanimated: ^1.13.2 => 1.13.2 react-native-render-html: ^4.2.0 => 4.2.4 react-native-responsive-screen: ^1.4.2 => 1.4.2 react-native-safe-area-context: ^3.1.9 => 3.1.9 react-native-screens: ^2.17.1 => 2.17.1 react-native-swift: ^1.2.3 => 1.2.3 react-native-swipe-list-view: ^3.0.1 => 3.2.4 react-native-track-player: 1.2.7 => 1.2.7 react-native-unimodules: ^0.9.1 => 0.9.1 react-native-vector-icons: ^8.0.0 => 8.0.0 react-native-video: ^5.0.2 => 5.0.2 react-native-web: ^0.12.0-rc.1 => 0.12.3 react-native-webview: ^9.4.0 => 9.4.0 react-navigation: ^4.4.3 => 4.4.3 react-navigation-drawer: ^2.6.0 => 2.6.0 react-navigation-fluid-transitions: ^0.3.2 => 0.3.2 react-navigation-stack: ^2.10.2 => 2.10.2 react-navigation-tabs: ^2.10.1 => 2.10.1 react-redux: ^7.1.1 => 7.2.1 react-test-renderer: 16.13.1 => 16.13.1 redux: ^4.0.4 => 4.0.5 (3.7.2) redux-thunk: ^2.3.0 => 2.3.0 responsive-screen: 0.1.0 responsive-screen-orientation-change: 0.1.0 responsive-screen-styled-components: 0.1.0 rn-fetch-blob: ^0.12.0 => 0.12.0 rn-placeholder: ^3.0.0 => 3.0.3 sentry-expo: ^2.0.1 => 2.1.2 unimodules-app-loader: ^1.0.2 => 1.3.0 (1.0.2) unimodules-font-interface: ^5.0.0 => 5.3.0 (5.1.0) unimodules-image-loader-interface: ^5.0.0 => 5.3.0 (5.1.0) npmGlobalPackages: @aws-amplify/cli: 4.50.2 npm: 6.14.6 ```

Describe the bug

Since users have upgraded to iOS 14.5, they are complaining of inability to sign in with federatedSignIn. The app just crashes. Android users and non < iOS 14.5 seem to not have issues.

When attempting to sign in with Auth.federatedSignIn() (Google, Apple, Facebook) on iOS 14.5, it throws the error:

The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".' was thrown while invoking openAuth on target RNInAppBrowser with params ( "https://[id].auth.us-west-2.amazoncognito.com/oauth2/authorize?redirect_uri=[scheme]%3A%2F%2F&response_type=code&client_id=xvxxxxxxxxxxxxxxxx&identity_provider=Google&scope=email%20profile%20openid%20aws.cognito.signin.user.admin&state=xxxxxxxxxxxxxxxxxx&code_challenge=xxxxxxxxxxx&code_challenge_method=S256", "[scheme]://", { enableDefaultShare = 0; enableUrlBarHiding = 1; ephemeralWebSession = 0; showTitle = 0; }, 2148, 2149 )

Simulator Screen Shot - iPhone 12 Pro Max - 2021-06-14 at 12 34 32

Expected behavior

Expected that it would take to the correct social page to sign in correctly.

Reproduction steps

  1. On iOS 14.5 try to sign in to app with Auth.federatedSignIn() on Google, Facebook, or Apple
  2. In development it will throw the error. In production users on 14.5 are failing to sign in. The app crashes when they try to press the button that triggers Auth.federatedSignIn().

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

iPhone 12 Pro Max Simulator

Mobile Operating System

iOS14.5

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

Similar issues stating problems with Xcode 12.5 and iOS 14.5 on Auth0 https://github.com/auth0-samples/auth0-react-native-sample/issues/45 https://github.com/auth0/auth0-oidc-client-net/issues/189 Proposed fix: Since version 12.5 (released on 26 Apr 2021), Xcode no longer accepts an entire URL for the ASWebAuthenticationSession scheme value. This PR extracts the scheme from the URL and uses just that, instead of the whole /authorize URL. https://github.com/auth0/react-native-auth0/pull/369

Another user asking for help on the Amplify Discord: https://discord.com/channels/705853757799399426/707328986077855836/843841513242886194 https://discord.com/channels/705853757799399426/717109738101407866/843839133281550346

zacharywenner commented 3 years ago

Update

This may be fixed from InAppBrowser.

Issue: proyecto26/react-native-inappbrowser#256

Solution: proyecto26/react-native-inappbrowser#262

Temporary workaround you can use (works for me):

https://github.com/proyecto26/react-native-inappbrowser/pull/262#issuecomment-859641814

I'm not sure if this needs to be reinforced from Amplify, if so it can reopen

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.