react-native-google-signin / google-signin

Google Sign-in for your React Native applications
https://react-native-google-signin.github.io/
MIT License
3.19k stars 877 forks source link

[Apple] RNGoogleSignIn: Unknown error in google sign in. #1327

Closed Romick2005 closed 2 weeks ago

Romick2005 commented 2 weeks ago

I have searched open and closed issues for this issue.

This is not a bug report for DEVELOPER_ERROR

Minimal reproducible example

const response = await GoogleSignin.signIn();

What platform(s) does this occur on?

iOS

Summary

When doing iOS Google login and press continue two times in a row (for the first two screens), but on the last confirmation screen press cancel the I got: Error: RNGoogleSignIn: Unknown error in google sign in., Error Domain=com.google.GIDSignIn Code=-1 "access_denied" UserInfo={NSLocalizedDescription=access_denied}

If I press cancel on first or second screen, it works as expected: error.code === statusCodes.SIGN_IN_CANCELLED

So it is invalid error for the Apple Google login on third screen when press cancel.

Computer environment System: OS: macOS 14.5 CPU: (8) arm64 Apple M1 Memory: 345.17 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.20.3 path: /usr/local/bin/node Yarn: version: 1.22.17 path: /usr/local/bin/yarn npm: version: 10.7.0 path: /usr/local/bin/npm Watchman: version: 2024.07.15.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /Users/romick/.rbenv/shims/pod SDKs: iOS SDK: Platforms: - DriverKit 23.5 - iOS 17.5 - macOS 14.5 - tvOS 17.5 - visionOS 1.2 - watchOS 10.5 Android SDK: API Levels: - "28" - "29" - "30" - "31" - "33" - "34" Build Tools: - 28.0.3 - 29.0.2 - 29.0.3 - 30.0.2 - 30.0.3 - 31.0.0 - 33.0.0 - 33.0.1 - 34.0.0 System Images: - android-28 | Google APIs ARM 64 v8a - android-28 | Google ARM64-V8a Play ARM 64 v8a - android-31 | Google APIs ARM 64 v8a - android-32 | Google Play ARM 64 v8a - android-34 | Google Play ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2024.1 AI-241.15989.150.2411.11948838 Xcode: version: 15.4/15F31d path: /usr/bin/xcodebuild Languages: Java: version: 17.0.12 path: /usr/bin/javac Ruby: version: 3.3.3 path: /Users/romick/.rbenv/shims/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.3.1 wanted: ^18.3.1 react-native: installed: 0.75.2 wanted: ^0.75.2 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true newArchEnabled: false
Romick2005 commented 2 weeks ago

As it turns out there are two similar errors codes: OIDErrorCodeUserCanceledAuthorizationFlow and OIDErrorCodeProgramCanceledAuthorizationFlow. So I think we just need to add extra or check to have proper user canceled error: Replace: if (error.code == OIDErrorCodeUserCanceledAuthorizationFlow) { with: if (error.code == OIDErrorCodeUserCanceledAuthorizationFlow || error.code == OIDErrorCodeProgramCanceledAuthorizationFlow) {

image image

vonovak commented 2 weeks ago

Hello and thanks for reporting, Good catch! I published a work-around in 13.0.1. It will probably take months for it to be fixed in the official google SDK. Thank you 🙂