Expo 应用程序生产中出现 Descope 重定向 Uri 错误

问题描述 投票:0回答:1

我按照 https://docs.expo.dev/guides/authentication/#descope 上的教程进行操作。它说我可以使用下面的重定向URI

const redirectUri = AuthSession.makeRedirectUri();

但是,当我使用

npx expo start

运行应用程序时,它确实有效

但是,当我提交到应用商店时,它只是说

{"errorCode":"E011003","errorDescription":"Request is invalid","errorMessage":"The redirect_uri field must have a hostname","message":"The redirect_uri field must have a hostname"}

下面是我的代码

const descopeProjectId = "xxxxxx";
const descopeUrl = `https://api.descope.com/${descopeProjectId}`;
const redirectUri = AuthSession.makeRedirectUri();

export default function SignupOrLogin() {
    const [authTokens, setAuthTokens] = React.useState(null);
    const [userInfo, setUserInfo] = React.useState(null);
    const discovery = AuthSession.useAutoDiscovery(descopeUrl);
    const [userProfile, setUserProfile] = useState<UserProfile>({} as UserProfile)

    const [request, response, promptAsync] = AuthSession.useAuthRequest(
        {
            clientId: descopeProjectId,
            responseType: AuthSession.ResponseType.Code,
            redirectUri,
            usePKCE: true,
            scopes: ["openid", "profile", "email"],
        },
        discovery
    );

我尝试在网上搜索其他内容,但我不太确定用什么来代替redirectUri。

react-native oauth-2.0 oauth expo redirect-uri
1个回答
0
投票

我通过将参数放入 makeRedirectUri 来解决这个问题

const redirectUri = AuthSession.makeRedirectUri({
  native: "com.<accountName>.<projectNameOrID>://redirect",
});
© www.soinside.com 2019 - 2024. All rights reserved.