【问题标题】:Google OAuth not working out the box in react-native-app-authGoogle OAuth 无法在 react-native-app-auth 中使用
【发布时间】:2019-07-13 15:13:52
【问题描述】:

此代码来自google oauth example

const config = {
  issuer: 'https://accounts.google.com',
  clientId: 'GOOGLE_OAUTH_APP_GUID.apps.googleusercontent.com',
  redirectUrl: 'com.googleusercontent.apps.GOOGLE_OAUTH_APP_GUID:/oauth2redirect/google',
  scopes: ['openid', 'profile']
};

// Log in to get an authentication token
const authState = await authorize(config);

但是,在登录并被重定向到应用程序后,我收到一个错误:

client_secret is missing

在配置中添加 clientSecret 可以解决 iOS 上的问题。但是,在 android 上,添加 clientSecret 不允许我使用 google 登录,而是加载此错误页面,指出不允许使用 client_secret

所以它有点像第 22 条规则。如果我提供 clientSecret,我会收到来自 google 的无效请求错误并且无法进行身份验证。如果我不提供,验证后会出现“client_secret is missing”错误。

【问题讨论】:

    标签: react-native react-native-android google-oauth appauth


    【解决方案1】:

    firebase 中添加SHA1 key 并确保存在email 支持。

    【讨论】:

    • 我没有使用 firebase,但我确实在 console.cloud.google.com 上为该项目配置了支持电子邮件。
    【解决方案2】:

    将以下内容放入配置中:

    clientSecret: 'YOUR_SECRET_KEY',

    【讨论】:

    • 我试过这个并在原始问题中讨论过。这适用于 iOS,但在 android 上会呈现上述错误:Parameter not allowed for this message type: client_secret
    猜你喜欢
    • 2019-06-06
    • 2021-02-22
    • 2020-05-16
    • 2019-11-20
    • 1970-01-01
    • 1970-01-01
    • 2020-11-28
    • 1970-01-01
    • 2022-12-16
    相关资源
    最近更新 更多