SDK Version: 35
Platform: Android
Library: expo-google-sign-in (^7.0.0)
I’m having trouble obtaining a token from GoogleSignIn.signInAsync() when on Android. The dialogue appears, and seems to work as it is supposed to, but GoogleSignIn.signInAsync() 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):
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.
I feel kind of like this right now:
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?
Any help would be greatly appreciated!