admin管理员组文章数量:1368297
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.
.jpg
/* 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": ".danyalbabar.assistivenote"
},
"android": {
"versionCode": 2,
"package": ".danyalbabar.assistivenote",
"googleServicesFile": "./google-services.json",
"permissions": [ " " ],
"config": {
"googleSignIn": {
"certificateHash": "XXXX"
}
}
}
}
}
My google-services.json:
{
"project_info": {
"project_number": "XXXX",
"firebase_url": "",
"project_id": "era-gvision",
"storage_bucket": "era-gvision.appspot"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "XXXX",
"android_client_info": {
"package_name": ".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"
}
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://i.sstatic/MVfO2.jpg
/* 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": ".danyalbabar.assistivenote"
},
"android": {
"versionCode": 2,
"package": ".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.",
"project_id": "era-gvision",
"storage_bucket": "era-gvision.appspot."
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "XXXX",
"android_client_info": {
"package_name": ".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"
}
Share
Improve this question
edited Aug 25, 2019 at 17:47
DanyalBabar
asked Aug 15, 2019 at 6:19
DanyalBabarDanyalBabar
771 silver badge4 bronze badges
6 Answers
Reset to default 9eas
November 2022 update (android)
If you are using eas
and getting DEVELOPER_ERROR
:
- run
eas credentials
(follow the steps to get your SHA1) - Add the SHA1 to your android app in the firebase console (https://console.firebase.google./project/YOUR_FIREBASE_APP_ID/settings/general/)
- download the
google-services.json
(same URL from above) and place it inside your project folder - update your
app.json
to includeexpo.android.googleServicesFile: "./path/to/google-services.json"
- Also inside the
app.json
: double check that theexpo.android.package
matches the package from the googleServicesFile - Make sure to initialize the google sign without any arguments for android
GoogleSignin.configure()
If it still doesn't work
- Download your apk
- run
keytool -printcert -jarfile app.apk
(will print the SHA1) - Double check that the printed SHA1 from above matches the SHA1 in your firebase console (alternatively, you can see/manage your OAuth API keys at https://console.cloud.google./apis/credentials?project=YOUR_PROJECT_ID)
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./, 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 {
...
}
I solved it by following the official troubleshoot guide for this error: https://react-native-google-signin.github.io/docs/troubleshooting
To sum up, I used the wrong SHA-1.
To get the SHA-1 ./gradlew signingReport in root of /android folder.
The output will contain multiple SHA-1. You must take the first. The one at the TOP of the output. My mistake was that I took the last.
(If you have no /android folder you can generate it with npx expo prebuild mand)
Edit: setting the webClientId is not mandatory in the configure method. You could let the method parameters empty.
In my case, I had to pass in androidClientId and webClientId to the configure method,
GoogleSignin.configure({
webClientId: '',
androidClientId:'',
});
In order to get the credentials, select your project on this page https://console.cloud.google./apis/credentials
As I didnt have a webClientId profile in Google Console and I only wanted Android removing webClientId worked for me in the examples webClientId is the only attribute provided. Also adding client_type: 3 was required.
export default {
//webClientId: '732421745157-983dllmj1ea30oqi0j7g0ohd6veei1tm.apps.googleusercontent.',
androidClientId: '732421745157-983dllmj1ea30oqi0j7g0ohd6veei1tm.apps.googleusercontent.',
client_type: 3 };
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/
本文标签: javascriptExpo GoogleSignIn DEVELOPERERRORStack Overflow
版权声明:本文标题:javascript - Expo Google-Sign-In DEVELOPER_ERROR - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743672693a2519796.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论