react-native - 如何将 Expo AppAuth 模块与 IdentityServer4 一起使用
问题描述
我正在尝试使用 Expo AppAuth 模块在本机反应中使用 IdentityServer4 进行身份验证。似乎无法正确设置 redirectUri。当我重定向到 identityServer 时,我收到“无效的重定向 uri”错误。
这是我在身份服务器上的客户
return new List<Client>
{
new Client
{
ClientName = "client",
ClientId = "client",
RequirePkce = true,
AllowedGrantTypes = GrantTypes.Code,
RequireClientSecret = false,
RequireConsent = true,
RedirectUris =
{
"host.exp.Exponent" //Is this correct
},
AllowOfflineAccess = true,
RefreshTokenUsage = TokenUsage.ReUse,
AllowedScopes = { "openid", "profile"},
}
};
我对 AppAuth 的配置设置是
const config = {
issuer: 'http://localhost:3000',
clientId: 'client',
scopes: ['profile', 'openid'],
redirectUri: "host.exp.Exponent"
}
解决方案
您应该指定redirectUri
为地址值。
AppAuth 定义:
async function _executeAsync(props: OAuthProps): Promise<TokenResponse> {
if (!props.redirectUrl) {
props.redirectUrl = getDefaultOAuthRedirect();
}
assertValidProps(props);
return await ExpoAppAuth.executeAsync(props);
}
export function getDefaultOAuthRedirect(): string {
return `${ExpoAppAuth.OAuthRedirect}:/oauthredirect`;
}
推荐阅读
- swiftui - When does SwiftUI update its views?
- python - 如何使用 python 获取 Jenkins 从节点中空闲执行器的数量?
- node.js - 使用 webpack 时如何设置环境变量?
- php - $_POST 值在服务器上为空,但适用于 localhost
- python - 从 Python 中的给定条件中减去值
- c++ - 错误 LNK2038:检测到“_MSC_VER”不匹配:值“1900”与值“1600”不匹配
- multithreading - 使用 netmiko 的多线程队列
- python - 有没有办法使用 Python 或 Linux 从 .txt 文件中创建文件夹目录和 word 文档?
- hardhat - 成本估算工具
- c - 在 Code::Blocks 中使用 gcc 的预处理器指令(宏)中的问题