javascript - React Native 连接与 firebase 错误:“请提供适当的客户端 ID”
问题描述
错误:请提供适当的客户 ID
首先我创建了一个 firebase 项目,然后我创建了两个应用程序(Android 和 iOS)。在创建 Android 之后,我安装了 .json 文件,然后在构建 apk 之后,通过命令“expo fetch:android:hashes”,我刚刚获得了谷歌证书哈希(SHA-256),我在谷歌中输入了指纹应用程序。使用 IOS,我在创建应用程序后下载了 .plist 文件。
代码:
const config = {
androidClientId:
"//ID from client_id of the google json file",
iosClientId:
"//ID from string of the google plist file",
scopes: ["profile", "email"],
permissions: ["public_profile", "email", "gender", "location"],
};
export const AuthProvider = ({ children }) => {
const signInWithGoogle = async () => {
await Google.logInAsync(config).then(async (loginResults) => {
if (loginResults.type === "success") {
//success
}
});
};
return (
<AuthContext.Provider
value={{
user: null,
signInWithGoogle,
}}
>
{children}
</AuthContext.Provider>
);
};
export default function useAuth() {
return useContext(AuthContext);
}
APP.js
const { signInWithGoogle } = useAuth();
return (
<View>
<Button title="Login" onPress={signInWithGoogle} />
</View>
);
仅打印出客户端 ID 错误后,没有打开谷歌模式
解决方案
推荐阅读
- javascript - 如何在 GraphQL 中使用变异方法在模型中创建关系?
- html - Css 粘性位置将每个内容向下推
- javascript - 如何缩短动态列表中的 IF 条件?
- javascript - 合并排序在 React 中没有按预期工作
- html - 在Angular 8中将选择元素绑定到数组
- php - 如何使用从 POST 接收的变量将条目插入 SQL 表
- docker - docker macvlan - no route to host (container)
- python-3.x - Many to Many relationship Flask sqlalchemy and marshmallow
- reactjs - How does react-router keep components from unmounting with route changes?
- c++ - Array-Sum Operation