IOS react-native-fbsdk-next. Token is generated as expired. Error: Bad credentials, GraphErrorCodeKey: 190

311 Views Asked by At

my package json(expo48):

"dependencies": {
"@babel/preset-typescript": "^7.18.6",
"@react-native-community/art": "^1.2.0",
"@react-native-community/viewpager": "5.0.11",
"common": "1.0.0",
"deprecated-react-native-prop-types": "^4.0.0",
"expo": "^48.0.0",
"expo-apple-authentication": "\~6.0.1",
"expo-av": "\~13.2.1",
"expo-device": "\~5.2.1",
"expo-firebase-analytics": "\~8.0.0",
"expo-font": "\~11.1.1",
"expo-in-app-purchases": "\~14.1.1",
"expo-keep-awake": "\~12.0.1",
"expo-linear-gradient": "\~12.1.2",
"expo-linking": "\~4.0.1",
"expo-secure-store": "\~12.1.1",
"expo-store-review": "\~6.2.1",
"expo-updates": "\~0.16.4",
"mobx": "^5.8.0",
"mobx-react": "5.4.3",
"node-libs-react-native": "^1.0.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-i18next": "9.0.8",
"react-native": "0.71.3",
"react-native-animate-number": "^0.1.2",
"react-native-confetti": "0.1.0",
"react-native-fbsdk-next": "^11.2.0",
"react-native-gesture-handler": "\~2.9.0",
"react-native-google-mobile-ads": "^8.2.2",
"react-native-particles": "^0.0.8",
"react-native-progress": "^5.0.0",
"react-native-progress-circle": "^2.1.0",
"react-native-reanimated": "\~2.14.4",
"react-native-redash": "^14.1.1",
"react-native-responsive-screen": "^1.4.1",
"react-native-root-toast": "^3.3.0",
"react-native-star-rating": "^1.1.0",
"react-native-svg": "13.4.0",
"react-native-svg-charts": "5.3.0",
"react-native-swipe-gestures": "^1.0.5",
"react-native-web": "0.17.7",
"react-native-tracking-transparency": "0.1.2",
"react-test-renderer": "18.0.0"
}

This is how i'm getting my token:

 private getCurrentAccessToken = async ()=> {
    let token = '';
    if (Platform.OS === 'ios') {
      LoginManagerFB.setLoginBehavior('browser')
      const result = await AuthenticationToken.getAuthenticationTokenIOS();
      console.log(result.graphDomain,result.nonce)
      token = result?.authenticationToken;
    } else {
      LoginManagerFB.setLoginBehavior('native_with_fallback')
      const result = await AccessToken.getCurrentAccessToken();
      token = result?.accessToken;
    }
    return token;
  };

This is how i use the token from above:

  fbGraphRequest = async (url:string, parameters:{[key: string]: unknown;}, accessToken:string) => {
    return new Promise((resolve, reject) => {
        const infoRequest = new GraphRequest(url, { accessToken,parameters},
          (error, result) => {
              if (error) {
                  console.log('Error fetching data: ', error);
                  reject(error);
              } else {
                  resolve(result);
              }
          }
        );

        new GraphRequestManager().addRequest(infoRequest).start();
    });
  };

This is the error that i'm getting:

....
"NSLocalizedRecoverySuggestion":"Please log into this app again to reconnect your Facebook account.",
"com.facebook.sdk:FBSDKErrorDeveloperMessageKey":"Bad signature",
"com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCodeKey":190,
"com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey":400,
"com.facebook.sdk:FBSDKGraphRequestErrorKey":2
....

Using mac, xCode and physical device for testing is iphone 8. I have implemented all the necessary steps from the documentation (https://github.com/thebergamo/react-native-fbsdk-next#limited-login-ios) but nothing works.

Didn't work after: Restarting the phone. Install/uninistall facebook app on the phone. Clearing project, cache, podfile.lock, yarn.lock.

Note (working): Login is working if i don't pass the accessToken to GraphRequest So it look like this. const infoRequest = new GraphRequest(url, {parameters}....

I don't know how it's possible because official documentation said that accessToken is required for each call.

0

There are 0 best solutions below