android - 如何使用 ASP.NET Core 3.1 将 Android 应用程序集成到 Identity Server 以进行身份验证?
问题描述
我已经使用 Angular 模板创建了 ASP.NET Core 项目,并使用 Visual Studio 进行了身份验证。现在我正在开发 Android 应用程序,并希望将其与我现有的 ASP.NET CORE 3.1 WEB API(后端)集成。我在 appsettings.json 中为我的 android 应用添加了客户端,如下所示:
"IdentityServer": {
"Clients": {
"MyAngularApp": {
"Profile": "IdentityServerSPA"
},
"MyMobileApp": {
"Profile": "NativeApp"
}
}
}
当我调用我的配置端点“https://localhost:4042/_configuration/MyMobileApp”时,我得到了以下响应;
{"authority":"https://localhost:4042","client_id":"MyMobileApp","redirect_uri":"urn:ietf:wg:oauth:2.0:oob","post_logout_redirect_uri":"urn:ietf:wg:oauth:2.0:oob","response_type":"code","scope":"offline_access MyAppAPI openid profile"}
我有以下问题;
“urn:ietf:wg:oauth:2.0:oob”在 redirect_uri 中是什么意思?
当我在这样的客户端设置中添加 redirect_uri 时,
“MyMobileApp”:{“Profile”:“NativeApp”,“RedirectUri”:“com.example.myapplication”}
但是当我调用端点“https://localhost:4042/_configuration/MyMobileApp”时,我没有得到我定义的redirect_uri,作为回应,我得到了这个“redirect_uri”:“urn:ietf:wg:oauth:2.0:oob” . 那么,如何更改默认的 RedirectUri?
我在 Android 中使用 AppAuth 库与 Identity Server 集成。
解决方案
在 appsetting.json 中尝试您必须使用 IdentityServer - 客户端尝试这可能是您的问题将得到解决
"IdentityServer": {
"IssuerUri": "urn:sso.company.com",
"Clients": [
{
"Enabled": true,
"ClientId": "local-dev",
"ClientName": "Local Development",
"ClientSecrets": [ { "Value": "<Insert Sha256 hash of the secret encoded as Base64 string>" } ],
"AllowedGrantTypes": [ "implicit" ],
"AllowedScopes": [ "openid", "profile" ],
"RedirectUris": [ "https://localhost:5001/signin-oidc" ],
"RequireConsent": false
}
]
}
推荐阅读
- javascript - 幻灯片 HTML/CSS/JS 中的错误 x[index] 未定义”
- r - 如果字符串匹配另一个字符串的一部分,则替换字符串
- javascript - 使用常量操作道具与使用函数操作道具有什么区别?
- pine-script - 带有颜色变化松树脚本的警报
- php - Xdebug - 在 Step Debugging 中增加 var_display_max_depth
- asp.net - 使用 Entity Framework 和 AutoMapper 实现 ?include=attributes 查询字符串
- php - 带有 jQuery 和 Canvas 的轻量级签名板 - Drawpad
- ios - SKPaymentQueue finishTransactions 未从队列中删除交易
- python - KivyMD + Python 中的 Matplotlib 线图:TypeError:actualizar_timeline_ventas() 采用 1 个位置参数,但给出了 2 个
- c++ - 如何使用 avcodec 和 libx264 设置固定 (const) fps