Tor*_*Tor 2 android google-authentication react-native google-signin expo
一些细节:
在 Android 上,当我调用 GoogleSignIn.signInAsync() 时,对话出现,并且似乎按预期工作,但函数返回的承诺解析为undefined。
这是我的代码的简化摘录(我不显示警报和其他各种我认为不是我的问题/问题核心的东西):
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
Run Code Online (Sandbox Code Playgroud)
这是我的 app.json(以及一些注释,当然这些注释没有包含在实际文件中):
{
"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*
}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
文章阵营自带谷歌登录在与世博会,和文档,礼物的事情,就好像使用火力不只是一个制作方法世博谷歌登录工作,但将使其工作的方式(或至少这是我的阅读时的解释)。但是,我可能记错了,但我想我记得在使用 firebase 执行任何操作之前能够从 IOS 上的 GoogleSignIn.signInAsync() 中提取令牌。我不太清楚 firebase 在使 expo-google-sign-in 工作中应该扮演什么角色,并且有点困惑。(使用 firebase 可能仅仅是因为它是生成 google-services.json-file 的最简单方法吗?)
无论如何,我确实尝试过使用firebase。从https://console.firebase.google.com/单击“添加项目”时,我选择了一个现有的(用于在与我们的应用程序对应的网站上进行 google 登录的那个,并且已与expo-google-一起使用) app-auth在我们应用程序的先前迭代中取得了不同程度的成功)。
这是我合并的来自 console.developers.google.com 的项目:
来自合并的 Firebase 项目的一些图像:
我确实下载了 google-services.json-file,并将其添加到我的项目的根目录中。我不明白该文件的内容,但我看到其中包含来自我的 console.developers.google.com-project 的几个客户端 ID。
在 Android 上我未定义以下警报(但也许这在 Android 上是正常的,文档似乎确实表明此测试适用于 IOS):
import { AppAuth } from 'expo-app-auth'
const { URLSchemes } = AppAuth
alert(URLSchemes)
Run Code Online (Sandbox Code Playgroud)
作为旁注(可能相关也可能不相关):在添加 Facebook 登录时,我添加了来自 developer.facebook.com 上的“expo fetch:android:hashes”的“Facebook Key Hash”。然而,这并没有使登录在我的手机上工作(但它确实在我朋友的电话上工作)。当我从尝试使用 Facebook 登录时在手机上显示的错误消息中添加 facebook 密钥哈希后,它才开始在我自己的手机上工作。
我怀疑问题可能出在库上(而不是我的实现),并且库的文档是错误的/误导性的。我在这里更详细地介绍了这一点:https : //forums.expo.io/t/does-google-authentication-work-on-android-sdk-35/28754。因此,我也对可能对此有所帮助的反馈/信息非常感兴趣:
我已经坚持了一个星期左右,可以说更多
任何帮助(无论是解决方案还是指针)都将不胜感激!
我们确实深入了解了这一点。它与 google Playstore 在发布应用程序之前自动对 google-services.json 进行更改有关。
您可以在以下位置找到更多信息:Google Play 控制台?列表中有问题的应用程序(在我们的例子中是“com.toleio.no”)?发布管理(在侧边栏中) ? 应用签名(在侧边栏子菜单中)。在这里,您还可以找到上传您的应用程序时放在 google-services.json 中的密钥。对于firebase和/或谷歌开发者控制台中与android 相关的密钥/凭据,您将在其中放置哈希/指纹,将您找到的那些放在那里,而不是通过expo fetch:android:hashes获得的那些。
另外,不要 100% 肯定地接受这一点,但我认为其他人(在 IOS 上使用谷歌登录而不是在 Android 上使用谷歌登录)可以通过运行“expo build:android -t apk”来测试这是否也是他们的问题而不是简单的"expo build:android"。我认为,这使得 google-services.json 中的内容不会被替换,但可能会以阻止 google 缩小应用程序大小为代价。但是,如果您同时测试并替换散列/指纹,那么这两个操作可能会相互抵消。
如果被问到,我可以尝试更好地/更详细地解释。
| 归档时间: |
|
| 查看次数: |
3025 次 |
| 最近记录: |