Expo - AuthSession.startAsync 在获得令牌后突然停止重定向回应用程序

我有一个 expo react 本机应用程序,它使用 Expo AuthSession.startAsync 使用外部提供程序登录。


突然之间,它在获得访问令牌后停止重定向回应用程序,我不知道为什么,据我所知,一年多来没有任何变化,所以我对发生的事情完全感到困惑.


这是代码......基本上不会返回结果,它只是重定向到模式上查询字符串中带有#access_token的页面,但之后没有任何反应?


   const result = await AuthSession.startAsync({

        authUrl: url

    });


    if (result.type === "cancel") {

        // do nothing

    } else if (result.type !== "success") {

        Alert.alert("Error", "There was an error logging in to the external provider, please try again.");

    } else {

        const accessToken = result.params.access_token;

        console.log(accessToken);

        this.props.setAccountJwt(accessToken);

        navigate("Levels");

    }


月关宝盒
浏览 165回答 1
1回答

互换的青春

我找到了答案,与代码无关。我网站上的重定向页面只有一个脚本标签,仅此而已。我唯一的猜测是移动浏览器必须进行更新以不运行仅包含脚本文件的页面。只要我把一个完整的 html 页面放在那里,我的脚本块就在那里重定向,然后它就恢复了生机。window.location.replace('https://auth.expo.io/@@myapp' + window.location.hash);
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript