[英]Expo Go with Google/Facebook OAuth - auth.expo.io login screen - "Not Found"
我正在嘗試在本機 expo 托管應用程序中設置 google oauth。 我在 Expo Go 中使用我的應用程序時僅遇到以下問題- 當我創建應用程序構建時,oauth 流程完美運行。 但是很難以這種方式開發,我需要能夠通過 Expo Go 與非開發團隊成員共享一個工作應用程序。我已經設置了我認為與expo go google auth 文檔相同的流程描述過。 概述
其中myorg
是擁有該項目的組織帳戶 expo 的名稱, projectname
與 app.json 中的slug
的值相同。
設置后,我得到了這個 oauth 登錄方法的客戶端 ID 和客戶端密碼。
在我的應用程序代碼中,我按照說明使用 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
}
所以現在在我的應用程序中,當我點擊谷歌登錄按鈕時,我得到正確打開 web 瀏覽器的提示:
單擊它可正確打開 expo web 瀏覽器,但我看到一條“未找到”消息:
有關更多詳細信息,當我記錄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
}"
這里唯一有點出乎意料的值是redirectUri
和redirect_uri
,它們附加了一個/MyProject
,這與我在谷歌控制台中的重定向 uri 中輸入的不完全相同。 那是怎么附加到那里的? 這可能是問題所在嗎?
據我所知,我已經按照描述設置了所有內容。 這里“未找到”到底是什么? 這個特定的 expo 應用程序的 oauth 頁面? 我的 go 哪里設置錯了?
Facebook.useAuthRequest
相同的問題我也遇到了與 Facebook 提供程序模塊完全相同的問題。 相似代碼:
const [facebookRequest, facebookResponse, facebookPromptAsync] =
Facebook.useAuthRequest({
clientId: "facebook_app_id",
responseType: ResponseType.Code,
});
我還嘗試了在 iOS/Android 上使用 Facebook 最簡單的方式使用 expo-auth-session文章中的建議來添加useProxy: true
屬性,但這沒有區別。
const [facebookRequest, facebookResponse, facebookPromptAsync] =
Facebook.useAuthRequest(
{
clientId: "facebook_app_id",
responseType: ResponseType.Code,
},
{ useProxy: true }
);
facebook 登錄也會將 expo 瀏覽器打開到一個顯示“未找到”的空頁面
我在這里做錯了什么?
你有你的originalFullName
在你的 app.json 上指定嗎? 如果沒有,請嘗試添加它,例如originalFullName: "@your_username/your_app_name"
也許這個 github 問題可以幫助您, https://github.com/expo/expo/issues/19891 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.