Some details:
- I am using expo, more specifically expo SDK 35.
- I am using the library expo-google-sign-in.
- The functionality seems to be working on IOS, but not on Android.
- This is a managed expo app, not a bare/ejected one.
On Android, when I call GoogleSignIn.signInAsync(), the dialogue appears, and seems to work as it is supposed to, but the promise returned by the function resolves to undefined.
Here is a simplified extract from my code (where I don’t show alerts and various other stuff that I don’t think is central to my question/problem):
import * as GoogleSignIn from 'expo-google-sign-in'
...
let clientId = *cencored*
// If I understand the documentation correctly this parameter
// isn't really necessary on Android, but I've provided one anyway.
// Actually, I've tried several different ones.
await GoogleSignIn.initAsync({
clientId,
scopes: ['profile', 'email']
})
await GoogleSignIn.askForPlayServicesAsync()
const result = await GoogleSignIn.signInAsync()
// ^ dialogue opens and looks normal/working,
// but the variable named "result" ends up being undefined
Here is my app.json (along with a few comments that of course aren’t included in the actual file):
{
"expo": {
"version": "0.0.61",
"android": {
"package": "com.toleio.no",
"googleServicesFile": "./google-services.json",
// ^ I've also downloaded an actual file of this type from firebase
"versionCode": 61,
"config": {
"googleSignIn": {
"apiKey": *cencored*,
// ^ If I understand the documentation correctly
// this is uneccecary, but I added it just in case.
// I created it on https://console.developers.google.com/apis/credentials?project=signlab-prod
// and selecting Create credentials -> API key.
// I also tried a build where I tried "Web API key"
// from console.firebase.google.com.
"certificateHash": *cencored*
// ^ I don't know what this parameter is for exactly,
// and if I understand the documentation correctly it's
// irrellevant/unnececcary. But what I put here is the
// has that is called "Google Certificate Hash (SHA-1)"
// when I do the console command "expo fetch:android:hashes"
}
}
},
"sdkVersion": "35.0.0",
"facebookAppId": *cencored*,
"facebookDisplayName": "Toleio!",
"facebookScheme": *cencored*,
"name": "Toleio",
"description": "Making Sign Language Available for Everyone",
"slug": "toleio-app-norwegian",
"privacy": "unlisted",
"ios": {
"bundleIdentifier": "com.toleio.no",
"supportsTablet": true,
"usesAppleSignIn": true,
"config": {
"googleSignIn": {
"reservedClientId": : *cencored*
}
}
},
"scheme": "toleio",
// ^ I don't properly/fully understand what this parameter does,
// and don't know if it might be relevant somehow
"platforms": [
"ios",
"android"
],
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/iconWithPadding.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 30000
},
"assetBundlePatterns": [
"**/*"
],
"packagerOpts": {
"assetExts": [
"ttf",
"mp4",
"dae",
"obj",
"amf",
"3mf",
"3ds",
"jpg",
"assimp",
"fbx",
"pmd",
"vmd",
"ply",
"stl",
"vtk",
"vtp",
"sea",
"gltf",
"bin"
]
}
},
"hooks": {
"postPublish": [
{
"file": "sentry-expo/upload-sourcemaps",
"config": {
"organization": "signlab",
"project": "toleio-app",
"authToken": : *cencored*
}
}
]
}
}
The article React Native Google Sign-In with Expo, and the documentation, presents things as if using firebase isn’t just a way of making expo-google-sign-in work but the way of making it work (or at least that’s my interpretation when reading). However, I might remember incorrectly, but I think I remember being able to extract a token from GoogleSignIn.signInAsync() on IOS before doing anything with firebase. I don’t have a good understanding of exactly what role firebase is supposed to play in making expo-google-sign-in work, and am a bit confused. (Is firebase perhaps used simply because it’s the easiest way of generating a google-services.json-file? 🤔)
Anyway, I did try to use firebase. When clicking “Add project” from https://console.firebase.google.com/ I chose an existing one (the one that is used for google login on the website corresponding to our app, and has been used with expo-google-app-auth with varying success in previous iterations of our app).
This is the project from console.developers.google.com that I merged with:
Some images from the merged firebase project:
I did download the google-services.json-file, and added it to the root of my project. I don’t understand the content of that file, but I see that several of the client IDs from my console.developers.google.com-project are included in it.
The following alerts undefined for me on Android (but perhaps that’s normal on Android, the documentation did seem to suggest that this test was for IOS):
import { AppAuth } from 'expo-app-auth'
const { URLSchemes } = AppAuth
alert(URLSchemes)
As a sidenote (that may or may not be relevant): When adding Facebook-login I added “Facebook Key Hash” from “expo fetch:android:hashes” on developers.facebook.com. This, however, did not make the login work on my phone (it did however work on the phone of my friend). It only started working on my own phone once I added the facebook key hash from an error message that I was shown on my phone when trying to use Facebook login.
- Do any of you see at once what I’ve done wrong?
- Is there some step I should have done, but don’t mention?
- Do you have suggestions for things you would try if you were me?
- Do you have questions that potentially could bring us closer to a solution?
I have some suspicion that the problem could be with the library (as opposed to my implementation), and that the library's documentation is wrong/misleading. I go more into detail about this here: https://forums.expo.io/t/does-google-authentication-work-on-android-sdk-35/28754. I'm therefore also very interested in feedback/info that could help in regards to that:
- Are there anyone here who can confirm that they’ve gotten google authentication to work on Android?
- And are there anyone here who can confirm that they’ve gotten google authentication to work on Android with expo-SDK 35?
- Are there anyone here who have gotten google authentication to work on Android with this library, but with an ejected/bare app - not a managed one?
I've been stuck on this for a week or so, arguably more 😟
Any help (be that a solution, or just a pointer) would be greatly appreciated! 🙂