我正在expo 上使用official documentation实现谷歌身份验证.在他们的示例中,他们使用以下代码块:

const [request, response, promptAsync] = Google.useAuthRequest({
  androidClientId: 'GOOGLE_GUID.apps.googleusercontent.com',
  iosClientId: 'GOOGLE_GUID.apps.googleusercontent.com',
});

但是,当我try 使用此代码时,我收到错误:Error: Client Id property 100 must be defined to use Google auth on this platform.

有人知道这个expoClientId应该是什么吗?我看到还有SO post人在使用Facebook,其中expoClientId人被指定为FBID人.

推荐答案

根据文档,在使用EXPO GO应用程序时,expoClientId是必需的,因为EXPO将作为您的身份验证请求的代理.与Android或iOS客户端ID相同的not.

要生成用于Google身份验证的expoClientId,请在Google Cloud平台上执行以下操作:

  1. 创建新的OAuth客户端ID,但将类型设置为Web Application.
  2. Authorized JavaScript origins设置为https://auth.expo.io
  3. Authorized redirect URIs设置为https://auth.expo.io/@{username}/{SLUG}.一个完整的例子是https://auth.expo.io/@abundance/MyExampleProject
  4. 使用生成的客户端ID作为EXPO客户端ID.

你必须登录到EXPO CLI,弹头可以在app.json文件中找到.

React-native相关问答推荐

每当我在 React Native Tab Navigator 中切换标签时触发 UseEffect

导出命名空间应首先由 `@babel/plugin-proposal-export-namespace-from` 转换

使用react native 杀死应用程序后蓝牙仍处于活动状态

如何防止 VS Code 从react-native-web自动导入?

Error: Invariant Violation: Touchable child must either be native or forward setNativeProps to a native component stack

如何在react-native 中设置视图的自动高度

React Native 白色黑屏问题

react-native redux 和 ListView

异步(async)/等待(await)和递归

如何从 stack.navigation 外部的组件中使用 navigation.navigate

null 不是对象(判断 this.state.count)

React Native:ScrollView 中的 TouchableOpacity onPress 问题

React native - 创建单例模式的最佳方式

使用 WSL2 运行时如何将手机连接到 expo

FlatList vs map react-native

创建新的 react-native 元素时出现Unexpected token import错误

KeyboardAvoidingView - 隐藏键盘时重置高度

如何更改键盘上的 return按钮?

如何在react-native中显示toast消息

如何将图形 API 与 react-native-fbsdk 一起使用?