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

使用expo-auth-session配置开发环境Google重定向URL的问题

Expo Auth Session 开发环境Google OAuth 400错误问题

我们正在基于React Native构建移动应用,使用expo-auth-session库实现原生支持的Google OAuth流程。生产环境下,配置类似com.mydomain.myapp:/oauth的重定向URI可以正常工作,但在开发环境使用该库提供的本地HTTP服务器时,配置exp://192.168.128.57:19000/--/oauth2这类重定向URI会触发Google的“Access blocked: authorisation error”错误(具体为Error 400: invalid_request)。尝试使用exp://localhost:19000/--/oauth2作为重定向URI,同样出现400错误。

代码示例

const redirectUri = makeRedirectUri({
    scheme: 'com.mydomian.myapp',
    path: '/oauth2',
    preferLocalhost: true  // 也试过设为false
});


const [request, response, promptAsync] = Google.useAuthRequest({
    androidClientId: ANDROID_CLIENT_ID,
    iosClientId: IOS_CLIENT_ID,
    redirectUri: redirectUri,
    scopes: ["profile", "email"]
}, {
    useProxy: false
});

内容的提问来源于stack exchange,提问作者Abhinaba

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.24 01:28:12