You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用React Native Expo接入Google登录时出现Redirect URI错误

Expo Auth Session Google登录Redirect URI问题求助

我使用expo-auth-session实现Google登录鉴权,已完成Android与iOS应用的对应配置,但始终被Redirect URI问题难住,恳请各位提供解决思路!

Google登录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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 09:07:12