【发布时间】:2021-11-18 11:45:29
【问题描述】:
SDK 版本:43.0.0
平台(Android/iOS/web/all):Android
您好,我在托管工作流程中使用 expo-auth-session 通过其官方 API 收集 Instagram 用户数据,它在开发环境中运行良好(通过“expo run:android”命令),但是一旦build APK 是在用户进行授权过程并且重定向开始时创建的,有一个弹出窗口询问“打开方式”和我的应用程序的两个选项,第一个完美运行第二个返回应用程序但什么也不做,我没有不要在 IOS 上测试。
这是代表它的图像: Click here to see
在开发时,我尝试执行 google 登录过程,但遇到了同样的错误,通过实现 google 原生登录部分解决了。我在 app.json 中验证了我的方案,但没有发现错误,如下:
app.json:
{
"expo": {
"name": "Secreet",
"slug": "secreet",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"scheme": "com.davidtmiranda.secreet",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"usesAppleSignIn": true,
"bundleIdentifier": "com.davidtmiranda.secreet",
"googleServicesFile": "./GoogleService-Info.plist",
"config": {
"googleSignIn": {
"reservedClientId": "com.googleusercontent.apps.--------------------"
}
}
},
"android": {
"versionCode": 1,
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.davidtmiranda.secreet",
"googleServicesFile": "./google-services.json"
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
另外,我的 authSession 代码如下所示:
webBrowser.maybeCompleteAuthSession();
const useProxy = Platform.select({ web: false, default: true });
const client_id = ---;
const redirect_uri = "https://auth.expo.io/@davidtmiranda/secreet";
const scope = "user_profile";
const site =
"https://api.instagram.com/oauth/authorize?client_id=" +
client_id +
"&redirect_uri=" +
redirect_uri +
"&scope=" +
scope +
"&response_type=code&state=1";
const discovery = { authorizationEndpoint: site };
const [request, response, promptAsync] = useAuthRequest(
{
redirectUri: makeRedirectUri({
useProxy,
native: redirect_uri,
}),
scopes: [scope],
clientId: String(client_id),
},
discovery
);
useEffect(() => {
if (response?.type === "success") {
...
}
}, [response]);
function GetInstagramID() {
return promptAsync({
useProxy,
});
}
关于如何解决这个问题的任何建议?我认为它与架构有关,但无法确定问题所在。
【问题讨论】:
标签: android react-native oauth-2.0 expo url-scheme