Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect after social provider sign in doesn't work [Android only] #14058

Closed
3 tasks done
Cristi6 opened this issue Dec 9, 2024 · 2 comments
Closed
3 tasks done

Redirect after social provider sign in doesn't work [Android only] #14058

Cristi6 opened this issue Dec 9, 2024 · 2 comments
Labels
Auth Related to Auth components/category pending-maintainer-response Issue is pending a response from the Amplify team. question General question

Comments

@Cristi6
Copy link

Cristi6 commented Dec 9, 2024

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

Amplify Gen 2

Environment information

# Put output below this line
System:
    OS: macOS 14.3
    CPU: (12) arm64 Apple M3 Pro
    Memory: 58.16 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 4.4.1 - ~/.nvm/versions/node/v20.12.2/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 9.10.0 - ~/.nvm/versions/node/v20.12.2/bin/pnpm
    Watchman: 2024.05.06.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 131.0.6778.109
    Safari: 17.3
  npmPackages:
    %name%:  0.1.0 
    @aws-amplify/backend: ^1.2.1 => 1.2.1 
    @aws-amplify/backend-cli: ^1.2.6 => 1.2.6 
    @aws-amplify/react-native: ^1.1.5 => 1.1.5 
    @aws-amplify/rtn-web-browser: ^1.1.0 => 1.1.0 
    @aws-sdk/client-dynamodb: ^3.699.0 => 3.699.0 
    @aws-sdk/lib-dynamodb: ^3.699.0 => 3.699.0 
    @babel/core: ^7.20.0 => 7.25.2 
    @babel/preset-env: ^7.20.0 => 7.25.4 
    @babel/runtime: ^7.20.0 => 7.25.6 
    @gorhom/bottom-sheet: ^5.0.5 => 5.0.5 
    @react-native-async-storage/async-storage: ^2.0.0 => 2.0.0 
    @react-native-community/netinfo: ^11.4.0 => 11.4.0 
    @react-native-firebase/app: ^21.6.0 => 21.6.0 
    @react-native-firebase/messaging: ^21.6.0 => 21.6.0 
    @react-native/babel-preset: 0.75.3 => 0.75.3 
    @react-native/eslint-config: 0.75.3 => 0.75.3 
    @react-native/metro-config: 0.75.3 => 0.75.3 
    @react-native/typescript-config: 0.75.3 => 0.75.3 
    @react-navigation/native: ^6.1.18 => 6.1.18 
    @react-navigation/native-stack: ^6.11.0 => 6.11.0 
    @sentry/react-native: ^5.32.0 => 5.32.0 
    @types/react: ^18.2.6 => 18.3.5 
    @types/react-native-get-random-values: ^1 => 1.8.2 
    @types/react-test-renderer: ^18.0.0 => 18.3.0 
    aws-amplify: ^6.6.0 => 6.6.0 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    aws-cdk: ^2 => 2.158.0 
    aws-cdk-lib: ^2 => 2.158.0 
    babel-jest: ^29.6.3 => 29.7.0 
    babel-plugin-module-resolver: ^5.0.2 => 5.0.2 
    constructs: ^10.0.0 => 10.3.0 
    dayjs: ^1.11.13 => 1.11.13 
    esbuild: ^0.23.1 => 0.23.1 
    eslint: ^8.19.0 => 8.57.0 
    eslint-plugin-import: ^2.30.0 => 2.30.0 
    eslint-plugin-unused-imports: ^4.1.4 => 4.1.4 
    i18next: ^23.15.1 => 23.15.1 
    intl-pluralrules: ^2.0.1 => 2.0.1 
    jest: ^29.6.3 => 29.7.0 
    prettier: 2.8.8 => 2.8.8 (2.3.2, 1.19.1)
    react: 18.3.1 => 18.3.1 
    react-error-boundary: ^4.0.13 => 4.0.13 
    react-hook-form: ^7.53.0 => 7.53.0 
    react-i18next: ^15.0.1 => 15.0.1 
    react-native: 0.75.3 => 0.75.3 
    react-native-config: ^1.5.3 => 1.5.3 
    react-native-date-picker: ^5.0.7 => 5.0.7 
    react-native-gesture-handler: ^2.21.0 => 2.21.0 
    react-native-get-random-values: ^1.11.0 => 1.11.0 
    react-native-keyboard-controller: ^1.14.5 => 1.14.5 
    react-native-localize: ^3.3.0 => 3.3.0 
    react-native-reanimated: ^3.16.1 => 3.16.1 
    react-native-safe-area-context: ^4.11.0 => 4.11.0 
    react-native-screens: ^3.34.0 => 3.34.0 
    react-native-svg: ^15.6.0 => 15.6.0 
    react-native-toast-message: ^2.2.0 => 2.2.0 
    react-native-unistyles: ^2.9.2 => 2.9.2 
    react-native-url-polyfill: ^2.0.0 => 2.0.0 
    react-test-renderer: 18.3.1 => 18.3.1 
    tsx: ^4.19.1 => 4.19.1 
    typescript: ^5.0.0 => 5.6.2 (4.4.4, 4.9.5)
    zustand: ^4.5.5 => 4.5.5 
  npmGlobalPackages:
    corepack: 0.25.2
    firebase-tools: 13.8.3
    npm: 10.5.0

Describe the bug

Hi,

I've added sign in with social providers (Google and Apple) as suggested in the documentation and everything works fine on iOS but on Android (both emulator and real device) the redirect back to the app after successful account selection doesn't work. For example with Google, once the browser opens and I select the account it stays in infinite loading forever, see below image:
Screenshot_20241209-123732

If I close the browser and trigger again signInWithRedirect({ provider: 'Google' }) the browser opens with a blank page, see below image:
Screenshot_1733739927

Have I missed any additional Android configuration?

Expected behavior

I'd expect once the account is selected to redirect back to the app with a successful sign in, just as it happens on iOS.

Reproduction steps

  1. Install packages
  2. Setup amplify auth & Google as external identity provider
  3. Trigger sign in with Google
  4. Confirm Google account

Code Snippet

My auth definition:

import { defineAuth, secret } from '@aws-amplify/backend';

/**
 * Define and configure your auth resource
 * @see https://docs.amplify.aws/gen2/build-a-backend/auth
 */
export const auth = defineAuth({
  loginWith: {
    email: true,
    externalProviders: {
      google: {
        clientId: secret('GOOGLE_CLIENT_ID'),
        clientSecret: secret('GOOGLE_CLIENT_SECRET'),
        scopes: ['email', 'profile'],
        attributeMapping: { email: 'email', givenName: 'given_name' },
      },
      signInWithApple: {
        clientId: secret('SIWA_CLIENT_ID'),
        keyId: secret('SIWA_KEY_ID'),
        privateKey: secret('SIWA_PRIVATE_KEY'),
        teamId: secret('SIWA_TEAM_ID'),
        scopes: ['email', 'name'],
        attributeMapping: { email: 'email', givenName: 'name' },
      },
      callbackUrls: ['app.packagename://callback'],
      logoutUrls: ['app.packagename://logout'],
    },
  },

  userAttributes: {
    givenName: { required: false, mutable: true },
  },
});

Triggering sign in:

signInWithRedirect({ provider: 'Google' })

Log output

// Put your logs below this line


aws-exports.js

No response

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

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending a response from the Amplify team. labels Dec 9, 2024
@chrisbonifacio chrisbonifacio added the Auth Related to Auth components/category label Dec 9, 2024
@HuiSF
Copy link
Member

HuiSF commented Dec 9, 2024

Hi @Cristi6 since your iOS is working correctly, I suspect the Android redirect after signing in failed due to configurations. Could you double check whether you have the Android intent-filter registered and it matches the redirect URL you specified? See this documentation for more details.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Dec 9, 2024
@HuiSF HuiSF added question General question pending-community-response Issue is pending a response from the author or community. labels Dec 9, 2024
@github-actions github-actions bot removed the pending-triage Issue is pending triage label Dec 9, 2024
@Cristi6
Copy link
Author

Cristi6 commented Dec 9, 2024

Yes, I can confirm the intent-filter fixes the issue, read only the Amplify Gen 2 documentation. Maybe it would be helpful to be added in the documentation there as well.

@Cristi6 Cristi6 closed this as completed Dec 9, 2024
@github-actions github-actions bot added pending-maintainer-response Issue is pending a response from the Amplify team. and removed pending-community-response Issue is pending a response from the author or community. labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auth Related to Auth components/category pending-maintainer-response Issue is pending a response from the Amplify team. question General question
Projects
None yet
Development

No branches or pull requests

3 participants