使用 Google 登录的 Expo 应用程序未重定向到应用程序

Ren*_*las 7 react-native google-signin expo

我的 Google 登录有问题,我目前正在使用 EXPO 应用程序,我希望不惜一切代价不要弹出/选择退出 Expo,问题是当我单击按钮在我的应用程序中使用 Google 登录时,它确实会带我进入浏览器内的登录页面,但一旦我输入我的 Google 凭据,它就会进入 Google.com 页面。

我检查了很多帖子,但仍然无法让它返回到应用程序。

我的应用程序登录代码是:

//import de Google en Expo
import * as Google from 'expo-google-app-auth';
import * as AppAuth from 'expo-app-auth';

export const googleLogin = () => {
    console.log('***Entro en Google***');
    return async dispatch => {
        try {
            const result = await Google.logInAsync({
              androidClientId: '***my ID Censored***',
              scopes: ['profile', 'email'],
              behavior: 'web',
              redirectUrl: `${AppAuth.OAuthRedirect}:/oauthredirect`
            });
            console.log('***Hizo Consulta***');
            if (result.type === 'success') {
              console.log(result.accessToken);
            } else {
              return { cancelled: true };
            }
          } catch (e) {
            return { error: true };
          }
    }
};
Run Code Online (Sandbox Code Playgroud)

我查了很多帖子,发现问题出在重定向 URL 上,我尝试设置 4 个选项:

  1. ${AppAuth.OAuthRedirect}:/oauthredirect
  2. ${AppAuth.OAuthRedirect}:/oauthredirect/google
  3. 'host.exp.exponent:/oauth2redirect/google'
  4. 'host.exp.exponent:/oauth2redirect/'

它们都不起作用,我做了 host.exp.exponent 的最后 2 个,因为这是 Expo 在其文档中使用的捆绑标识符:

https://docs.expo.io/versions/latest/sdk/google/

创建 Android OAuth 客户端 ID

  1. 选择“Android 应用程序”作为应用程序类型。如果需要,可以给它起一个名字(也许是“Android Development”)。
  2. 运行 openssl rand -base64 32 | 在终端中输入 openssl sha1 -c ,它将输出一个看起来像 A1:B2:C3 但更长的字符串。将输出复制到剪贴板。将上一步的输出粘贴到“签名证书指纹”文本字段中。
  3. 使用 host.exp.exponent 作为“包名称”。4.点击“创建”
  4. 您现在将看到一个带有客户端 ID 的模式。
  5. 客户端 ID 用于 Google.loginAsync 的 androidClientId 选项(请参阅下面的代码示例)。

我就是这么做的,现在它总是卡在 google.com 页面上,有什么想法或建议吗?

亲切的问候

小智 -1

在 app.json 中,包名称全部为小写字母,例如 com.app.cloneapp