使用React Native Expo接入Google登录时出现Redirect URI错误
Expo Auth Session Google登录Redirect URI问题求助
我使用expo-auth-session实现Google登录鉴权,已完成Android与iOS应用的对应配置,但始终被Redirect URI问题难住,恳请各位提供解决思路!

当前实现代码:
import React, { createContext, useContext } from 'react'; import * as Google from 'expo-auth-session/providers/google'; const AuthContext = createContext({}); export const AuthProvider = ({ children }) => { const config = { androidClientId: "redacted", iosClientId: "redacted", }; const [request, response, promptAsync] = Google.useAuthRequest(config); const signInWithGoogle = async () => { try { await promptAsync(); // Wait for the authentication prompt // Additional logic after authentication // For example, you can fetch user data here } catch (error) { console.error("Error during Google sign-in:", error); } }; return ( <AuthContext.Provider value={{ user: null, signInWithGoogle: signInWithGoogle, }} > {children} </AuthContext.Provider> ); }; export default function useAuth() { return useContext(AuthContext); }
已尝试的解决方法:
- 在配置中显式添加redirectUri,代码如下:
const config = { androidClientId: "redacted", iosClientId: "redacted", redirectUri: "redacted", };
- 将iOS的bundleId/Android的包名作为redirectUri,但均未成功。
内容的提问来源于stack exchange,提问作者Ayub Abdi
相关产品推荐
相关产品推荐

