4
votes

I developed a React Native app, and I am using Expo Google-Sign-In for my Firebase authentication. I receive the error "DEVELOPER_ERROR" when I attempt authentication on my standalone APK on Android.

Initially, I was using "Expo Google", however that is now deprecated and my sign-in button did not do anything on my standalone APK. With Expo Google method, I found that I had to set the androidStandaloneAppClientId. Even after that, the sign-in got stuck at the Google homepage after authentication. I tried the solution of using a custom redirect URI, as in

redirectUrl: ${AppAuth.OAuthRedirect}:/oauth2redirect/google

but that resulted in another error: redirect_uri mismatch.

I switched to the Expo Google-Sign-In library instead, and that is giving me a DEVELOPER_ERROR every time I try to authenticate.

After that, I have tried:

  • downloading the google-services.json and using it in my app
  • setting the SHA1 fingerprint in google-services.json and in Firebase
  • setting the certificateHash inside android.configuration.certificate hash inside my app.json to my SHA1 fingerprint.
  • checking and making sure package names are set properly

I tried anything else I may have failed to mention from the existing threads involving DEVELOPER_ERROR in Expo Google-Sign-In.

The variables I mention in my code below are from the following:

SHA1 was generated and used to create my credential, and is the fingerprint used in my OAuth Android Client ID.

The client ID I reference throughout my files is the ID of my OAuth Web client ID. However, I also tried using the Android one and that did not change anything.

"CurrentKey" in api_key is the API key from my Firebase project.

This is a link to my Google Credentials page.

https://imgur.com/a/u8cPxQl

/* My app.json: */

{
  "expo": {
    "name": "AssistiveNote",
    "privacy": "public",
    "description": "A note app for people who have trouble reading text.",
    "slug": "assistivenote",

    "sdkVersion": "33.0.0",
    "version": "2.0.0",
    "orientation": "portrait",
    "icon": "./screens/images/icon.png",


    "ios": {
      "bundleIdentifier": "com.danyalbabar.assistivenote"
    },

    "android": {
      "versionCode": 2,
      "package": "com.danyalbabar.assistivenote",
      "googleServicesFile": "./google-services.json",
      "permissions": [ " " ],
      "config": {
        "googleSignIn": {
            "certificateHash": "XXXX"
        }
      }
    }

  }
}

My google-services.json:

  {
  "project_info": {
    "project_number": "XXXX",
    "firebase_url": "https://era-gvision.firebaseio.com",
    "project_id": "era-gvision",
    "storage_bucket": "era-gvision.appspot.com"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "XXXX",
        "android_client_info": {
          "package_name": "com.danyalbabar.assistivenote"
        }
      },
      "oauth_client": [
        {
          "client_id": "XXXX",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "XXXX"
        }
      ],
      "services": {
        "appinvite_service": {
          "other_platform_oauth_client": [
            {
              "client_id": "XXXX",
              "client_type": 3
            }
          ]
        }
      }
    }
  ],
  "configuration_version": "1"
}
2

2 Answers

1
votes

This is configuration mismatch. Make sure that your android/app/google-services.json is correct.

You may need to add your SHA certificate fingerprint to your Firebase config. Find your SHA1 fingerprint by following the instructions on this post: SHA-1 fingerprint of keystore certificate. Then, go to https://console.firebase.google.com/, select your app, and add the SHA1 value under Project Settings (gear icon in the upper left) -> Your Apps -> SHA certificate fingerprints

If you're passing webClientId in configuration object to GoogleSignin.configure() make sure it's correct. You can get your webClientId from Google Developer Console. They're listed under "OAuth 2.0 client IDs".

If you're running your app in debug mode and not using webClientId or you're sure it's correct the problem might be signature (SHA-1 or SHA-256) mismatch. You need to add the following to android/app/build.gradle:

signingConfigs {
  debug {
       storeFile file(MYAPP_RELEASE_STORE_FILE)
       storePassword MYAPP_RELEASE_STORE_PASSWORD
       keyAlias MYAPP_RELEASE_KEY_ALIAS
       keyPassword MYAPP_RELEASE_KEY_PASSWORD
  }
  release {
       ...
  }
0
votes

Overall it seemed like there was a lot of broken behaviour with this API and it is now deprecated. I moved on to use email/password authentication at the time, but there are now updated Expo APIs that are implemented in new ways.

https://docs.expo.io/guides/authentication/