简体   繁体   English

Expo Go 与谷歌/Facebook OAuth - auth.expo.io 登录屏幕 - “未找到”

[英]Expo Go with Google/Facebook OAuth - auth.expo.io login screen - "Not Found"

I am trying to set up google oauth in a react native, expo managed app.我正在尝试在本机 expo 托管应用程序中设置 google oauth。 I am only having the following issue using my app within Expo Go - when I create a build of the app, the oauth flow works perfectly.我在 Expo Go 中使用我的应用程序时仅遇到以下问题- 当我创建应用程序构建时,oauth 流程完美运行。 But its hard to develop that way, and I need to be able to share a working app with non-dev team members via Expo Go. I have set up the flow in what I think is the same as what the expo go google auth documentation has described.但是很难以这种方式开发,我需要能够通过 Expo Go 与非开发团队成员共享一个工作应用程序。我已经设置了我认为与expo go google auth 文档相同的流程描述过。 An overview概述

  • Create a project in google console, and set up a new ClientID for web applications.在google console中新建一个项目,为web应用设置一个新的ClientID。 Set the authorized origins and redirect uri:设置授权来源和重定向 uri:

Where myorg is the name of the expo organizational account that owns the project, and projectname is the same value as slug in app.json.其中myorg是拥有该项目的组织帐户 expo 的名称, projectname与 app.json 中的slug的值相同。

  • After setting this up, I get the client id, and client secret for this oauth login method.设置后,我得到了这个 oauth 登录方法的客户端 ID 和客户端密码。

  • In my app code, I follow the instructions to use the expo-auth-session library for google:在我的应用程序代码中,我按照说明使用 google 的expo-auth-session库:

import * as WebBrowser from "expo-web-browser";
import * as Google from "expo-auth-session/providers/google";

WebBrowser.maybeCompleteAuthSession();

export const OAuthButtons: React.FC = () => {
  const [request, response, promptAsync] = Google.useAuthRequest({
    expoClientId: "clientId-from-google-console.apps.googleusercontent.com",
    iosClientId: "will set this up eventually",
    androidClientId: "will set this up eventually",
  });

  return; // markup for sign in buttons

}

So now in my app, when I click the google sign in button, I get the prompt to open the web browser correctly:所以现在在我的应用程序中,当我点击谷歌登录按钮时,我得到正确打开 web 浏览器的提示:

在此处输入图像描述

Clicking that correctly opens the expo web browser, but I see a "not found" message:单击它可正确打开 expo web 浏览器,但我看到一条“未找到”消息:

在此处输入图像描述

For more details, when I log the request , I get some pretty expected values有关更多详细信息,当我记录request时,我得到了一些非常期望的值

"{
  "url": "https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=https%3A%2F%2Fauth.expo.io%2FMyProject&client_id=id-from-console.apps.googleusercontent.com&response_type=token&state=5xWG83SsoJ&scope=openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email",
  "responseType": "token",
  "clientId": "client-id-from-console.apps.googleusercontent.com",
  "redirectUri": "https://auth.expo.io/MyProject",
  "scopes": [
    "openid",
    "https://www.googleapis.com/auth/userinfo.profile",
    "https://www.googleapis.com/auth/userinfo.email"
  ],
  "state": "5xWG83SsoJ",
  "extraParams": {},
  "codeChallengeMethod": "S256",
  "usePKCE": false
}"

The only values here that are a bit unexpected are the redirectUri and redirect_uri , which have a /MyProject appended to them, which is not exactly what I had put in my redirect uri in the google console.这里唯一有点出乎意料的值是redirectUriredirect_uri ,它们附加了一个/MyProject ,这与我在谷歌控制台中的重定向 uri 中输入的不完全相同。 How did that get appended there?那是怎么附加到那里的? Might that be the problem?这可能是问题所在吗?

As far as I can tell, I've set everything up as described.据我所知,我已经按照描述设置了所有内容。 What is it exactly that is "Not Found" here?这里“未找到”到底是什么? The oauth page for this particular expo application?这个特定的 expo 应用程序的 oauth 页面? Where did I go wrong in my setup?我的 go 哪里设置错了?

Edit - Same Problem with Facebook.useAuthRequest编辑 - 与Facebook.useAuthRequest相同的问题

I am having the same exact problem with the Facebook provider module as well.我也遇到了与 Facebook 提供程序模块完全相同的问题。 Similar code:相似代码:

  const [facebookRequest, facebookResponse, facebookPromptAsync] =
    Facebook.useAuthRequest({
      clientId: "facebook_app_id",
      responseType: ResponseType.Code,
    });

I also tried the suggestion from the article Use expo-auth-session with Facebook the Easiest Way on iOS/Android to add the useProxy: true property, but that makes no difference.我还尝试了在 iOS/Android 上使用 Facebook 最简单的方式使用 expo-auth-session文章中的建议来添加useProxy: true属性,但这没有区别。

  const [facebookRequest, facebookResponse, facebookPromptAsync] =
    Facebook.useAuthRequest(
      {
        clientId: "facebook_app_id",
        responseType: ResponseType.Code,
      },
      { useProxy: true }
    );

The facebook login also opens the expo browser to an empty page that says "Not found" facebook 登录也会将 expo 浏览器打开到一个显示“未找到”的空页面

What am I doing wrong here?我在这里做错了什么?

Do you have your originalFullName specify on your app.json?你有你的originalFullName在你的 app.json 上指定吗? If not, try to add it eg originalFullName: "@your_username/your_app_name"如果没有,请尝试添加它,例如originalFullName: "@your_username/your_app_name"

And maybe this github issue can help you, https://github.com/expo/expo/issues/19891 .也许这个 github 问题可以帮助您, https://github.com/expo/expo/issues/19891

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM