invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.69k stars 2.21k forks source link

[🐛] Cannot login via facebook using firebase - Error: [auth/invalid-credential] The supplied auth credential is malformed or has expired. [ Invalid access_token, error code 43 ] #7126

Closed proactivebit closed 1 year ago

proactivebit commented 1 year ago

Issue

Hi Recently I started getting error "Invalid access_token, error code 43" when I want to login to the app using facebook option and firebase integration. Before that everything works. I haven't change anything. Right now facebook developer team turn off my application from production because of this. I checked configuration and it seems be ok. When I do investigation I see that I get access token from facebook but when I send it to the firebase I get in response error 43. I also checked my other app and it looks that the problem is also visible there. Maybe it's some global problem? logs: LOG {"accessToken": "myaccesstoken", "accessTokenSource": "CHROME_CUSTOM_TAB", "applicationID": "myapplicationid", "dataAccessExpirationTime": 1692302693000, "declinedPermissions": [], "expirationTime": 1689683970908, "expiredPermissions": [], "lastRefreshTime": 1684526692908, "permissions": ["openid", "public_profile", "email"], "userID": "myuserid"} LOG [Error: [auth/invalid-credential] The supplied auth credential is malformed or has expired. [ Invalid access_token, error code 43 ]]

Project Files

Javascript

Click To Expand

![image](https://github.com/invertase/react-native-firebase/assets/9938300/53f68bf6-88cf-44ce-823c-8b53a873e406) #### `package.json`: ```json { "name": "PuzzleTracker", "version": "4.1.8", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "info": "react-native info", "start": "react-native start", "start:clear": "react-native start --reset-cache", "test:all": "jest \"__tests__/.*\\.spec\\.js\" --detectOpenHandles", "test": "jest --detectOpenHandles", "lint": "eslint --ext .js,.jsx,.ts,.tsx src/", "detox:build": "detox build -c android", "detox:test": "detox test -r -c android", "release": "./android/gradlew bundleRelease", "pod:install": "arch -x86_64 pod install", "setup:env": "source $HOME/.bash_profile", "clean:android": "cd ./android && ./gradlew clean && cd ..", "clean:ios": "cd ./ios && xcodebuild clean && cd .." }, "dependencies": { "@invertase/react-native-apple-authentication": "2.2.2", "@react-native-async-storage/async-storage": "1.17.11", "@react-native-camera-roll/camera-roll": "5.2.3", "@react-native-community/masked-view": "0.1.11", "@react-native-community/push-notification-ios": "1.10.1", "@react-native-firebase/analytics": "11.3.3", "@react-native-firebase/app": "11.3.3", "@react-native-firebase/auth": "11.3.3", "@react-native-firebase/crashlytics": "11.3.3", "@react-native-firebase/firestore": "11.3.3", "@react-native-firebase/functions": "11.3.3", "@react-native-firebase/in-app-messaging": "11.3.3", "@react-native-firebase/storage": "11.3.3", "@react-native-google-signin/google-signin": "6.0.1", "@react-navigation/drawer": "5.12.5", "@react-navigation/native": "5.9.4", "@react-navigation/stack": "5.14.5", "@reduxjs/toolkit": "^1.9.3", "add": "2.0.6", "date-fns": "2.22.1", "formik": "2.2.9", "i": "^0.3.6", "i18n-js": "3.8.0", "immutability-helper": "3.1.1", "lodash": "4.17.21", "nativewind": "^2.0.11", "qs": "6.11.0", "react": "18.2.0", "react-native": "0.71.3", "react-native-chart-kit": "6.11.0", "react-native-currency-input": "1.0.1", "react-native-date-picker": "4.2.8", "react-native-event-listeners": "1.0.7", "react-native-fbsdk-next": "11.2.0", "react-native-formik": "1.7.8", "react-native-fs": "2.18.0", "react-native-gesture-handler": "1.10.3", "react-native-get-random-values": "1.8.0", "react-native-iap": "12.7.3", "react-native-image-crop-picker": "0.39.0", "react-native-image-resizer": "1.4.5", "react-native-image-viewing": "0.2.2", "react-native-in-app-review": "3.2.3", "react-native-linear-gradient": "2.5.6", "react-native-localize": "2.2.4", "react-native-onboarding-swiper": "1.2.0", "react-native-pager-view": "5.4.25", "react-native-paper": "5.4.1", "react-native-push-notification": "7.4.0", "react-native-reanimated": "2.14.4", "react-native-safe-area-context": "3.2.0", "react-native-screens": "2.18.1", "react-native-share": "8.2.1", "react-native-snap-carousel": "3.9.1", "react-native-splash-screen": "3.2.0", "react-native-star-rating": "1.1.0", "react-native-svg": "12.1.1", "react-native-tab-view": "3.0.1", "react-native-timeline-flatlist": "0.7.6", "react-native-tracking-transparency": "0.1.1", "react-native-vector-icons": "7.1.0", "react-native-view-shot": "3.1.2", "react-redux": "^8.0.5", "realm": "11.4.0", "rn-fetch-blob": "0.12.0", "uuid": "8.3.2", "yarn": "1.22.10", "yup": "0.32.9" }, "devDependencies": { "@babel/core": "7.20.12", "@babel/preset-env": "^7.20.0", "@babel/preset-typescript": "^7.18.6", "@babel/runtime": "7.20.0", "@react-native-community/eslint-config": "3.2.0", "@realm/babel-plugin": "^0.1.1", "@realm/react": "^0.4.1", "@testing-library/jest-native": "4.0.13", "@testing-library/react-native": "7.2.0", "@tsconfig/react-native": "^2.0.2", "@types/jest": "29.2.1", "@types/lodash": "4.14.191", "@types/qs": "6.9.7", "@types/react": "18.0.24", "@types/react-native": "0.63.40", "@types/react-native-onboarding-swiper": "1.1.4", "@types/react-native-push-notification": "^8.1.1", "@types/react-native-snap-carousel": "3.8.5", "@types/react-native-star-rating": "1.1.2", "@types/react-native-vector-icons": "6.4.13", "@types/react-redux": "^7.1.25", "@types/react-test-renderer": "18.0.0", "@types/redux-logger": "3.0.9", "@types/uuid": "8.3.4", "@typescript-eslint/eslint-plugin": "5.52.0", "@typescript-eslint/parser": "5.52.0", "babel-jest": "29.2.1", "babel-plugin-dynamic-import-node": "2.3.3", "babel-plugin-module-resolver": "4.1.0", "detox": "18.18.1", "detox-getprops": "0.1.2", "eslint": "8.19.0", "eslint-config-codingitwrong": "0.1.4", "eslint-import-resolver-babel-module": "5.3.2", "eslint-import-resolver-typescript": "2.4.0", "eslint-plugin-detox": "1.0.0", "eslint-plugin-jest": "^27.2.1", "eslint-plugin-react": "7.24.0", "eslint-plugin-react-hooks": "^4.6.0", "jest": "29.2.1", "jest-circus": "26.6.3", "metro-react-native-babel-preset": "0.73.7", "moment": "2.29.4", "prettier": "2.4.1", "react-native-modal": "13.0.0", "react-native-set-version": "1.1.2", "react-test-renderer": "18.2.0", "reactotron-react-native": "^5.0.3", "reactotron-redux": "^3.1.3", "tailwindcss": "^3.2.7", "typescript": "4.8.4" }, "resolutions": { "@types/react": "18.0.28" }, "jest": { "preset": "react-native", "setupFilesAfterEnv": [ "@testing-library/jest-native/extend-expect" ], "setupFiles": [ "./node_modules/react-native-gesture-handler/jestSetup.js", "./mock.js", "./clearTestDBFolder.js" ], "moduleFileExtensions": [ "ts", "tsx", "js", "jsx", "json", "node" ], "transformIgnorePatterns": [ "node_modules/(?!react-native-iap)/" ] } } ``` #### `firebase.json` for react-native-firebase v6: ```json { "react-native": { "crashlytics_debug_enabled": true, "analytics_auto_collection_enabled": false, "crashlytics_auto_collection_enabled": false, "in_app_messaging_auto_collection_enabled": false }, "functions": { "predeploy": "npm --prefix \"$RESOURCE_DIR\" run build", "source": "functions" }, "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" }, "emulators": { "functions": { "port": 5001 }, "firestore": { "port": 8080 }, "pubsub": { "port": 8085 }, "ui": { "enabled": true } } } ```

Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS 13.2.1 CPU: (8) arm64 Apple M1 Memory: 78.20 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 17.9.1 - ~/.nvm/versions/node/v17.9.1/bin/node Yarn: 1.22.10 - ~/Projects/puzzleTimer/node_modules/.bin/yarn npm: 8.11.0 - ~/.nvm/versions/node/v17.9.1/bin/npm Watchman: 2023.04.03.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.18 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.3 => 0.71.3 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **Platform that you're experiencing the issue on**: - [ x] iOS - [x ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [x ] Both - **`react-native-firebase` version you're using that has this issue:** - `11.3.3` - **`Firebase` module(s) you're using that has the issue:** - `@react-native-firebase/auth` - **Are you using `TypeScript`?** - `Y` & `4.8.4`


github-actions[bot] commented 1 year ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

dcassou commented 1 year ago

Same issue here.

Facebook token is valid (tested with Meta dev tools token debugger) but somehow firebase returned the same error only for some users. Suspecting a Facebook app config or infrastructure issue but I have triple checked secrets, bundle, package... everything seems ok.

wil2106 commented 1 year ago

Same issue here. (@react-native-firebase/auth v18.1.0)

GaspardC commented 1 year ago

Same issue. Do you guys have a workaround?

proactivebit commented 1 year ago

No I don't have. There is no response from facebook team. I plan to migrate users from FB authentication to another option and remove FB login. I was waiting for 3 weeks for FB business verification with the hope that this is sth that is missing but they rejected me without any feedback. I give up.

dcassou commented 1 year ago

My understanding (till then I resigned and built another app):

Conclusion: I will never work unless Meta team does something but bots don't do.

mikehardy commented 1 year ago

Interesting. No single person here indicates if it is iOS or android or both. What platform is this affecting you on, out of curiosity?

I just did a facebook logout / login cycle on real devices and it worked on android / ios using react-native-firebase v17

I then rebuilt my app after updating it to react-native-firebase v18 and did the same facebook logout / login cycle on real devices android and ios and it worked?

I cannot reproduce this with my production app at least

dcassou commented 1 year ago

Hi @mikehardy, if my analysis is correct you won't be able to reproduce a bug on Meta side 😉

Yet I can give you dev access to my faulty app or an meta token if you want (and have time) to check what's behind the scene.

PS: exactly the same behavior on 🤖 and 🍎

github-actions[bot] commented 1 year ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

GaspardC commented 1 year ago

It was a problem on Facebook side for us... 😅 fbmessage

github-actions[bot] commented 1 year ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

trickeyd commented 3 months ago

We have been hitting this issue too. It only effects iOS so far

    "react-native": "0.74.3",
    "react-native-fbsdk-next": "13.0.0",
    "@react-native-firebase/app": "19.0.1",
    "@react-native-firebase/auth": "19.0.1",

Initially only some of us were able to replicate it initially - and we tried with 'limited' and 'enabled' but it made no difference. Now we have found that if we agree to ATT the login works, and if you don't login fails. Strangely though, once you replicate the failed login once, it seems to forever fail from that point onwards, for that Facebook account - regardless of cache clear, reinstall, different device, ATT choice etc etc.

NativeFirebaseError: [auth/invalid-credential] The supplied auth credential is malformed or has expired.
    at signInWithCredential
    at ?anon_0_
    at next
    at asyncGeneratorStep
    at _next
    at tryCallOne
    at anonymous
    at apply
    at anonymous
    at _callTimer
    at _callReactNativeMicrotasksPass
trickeyd commented 3 months ago

@GaspardC - by what channel did you contact Meta? I keep hitting dead ends, and refusal to deal with anything regarding login which they seem to consider somewhat depreciated.

GaspardC commented 3 months ago

@trickeyd it was on facebook developers platform, but sorry I don't remember exactly where

trickeyd commented 3 weeks ago

Did anyone get anywhere with this? I submitted our app to the troubleshooting review but got no response, and I have had endless calls chats in messenger, but can never get to anyone that even knows what I am talking about.

mikehardy commented 3 weeks ago

This happened to me before I correctly transitioned my app to limited login - where by "correctly transitioned" I mean I not only got a limited login token from react-native-fbsdk-next (I had already done that) but I started using it differently, as per the docs here https://rnfirebase.io/auth/social-auth#facebook-limited-login-ios-only - then it started working perfectly