我有一个Ionic Angular应用程序,我正在将其部署到Android设备上。我使用OpenID + KeyCloak进行身份验证,在客户端,我通过使用angular-auth-oidc-client来处理这个问题。我设置的配置是:
scope: 'openid profile tino_access',
silentRenewUrl: `${window.location.origin}/silent-renew.html`,
responseType: 'code',
postLogoutRedirectUri: window.location.origin,
silentRenew: true,
silentRenewUrl: `${window.location.origin}/silent-renew.html`,
logLevel: LogLevel.Warn,
postLoginRoute: window.location.origin,
useRefreshToken: true在本地部署或在我的服务器上自定义域上部署时,它可以很好地工作,但是当在手机上作为应用程序进行测试时,它不能工作。我注意到window.location.origin的值是http://localhost。成功登录后,将以令牌的形式发出请求,其中‘${window.location.origin}/?state='token'&code='token'’是由OAuth生成的令牌的值。当在移动设备上发出此请求时,请求http://localhost/?state=...&code=...无法识别,应用程序无法启动,我只能得到一个错误屏幕,指出该网页不存在。
有没有办法绕过这个问题?谢谢
发布于 2021-04-08 18:19:35
答:由于应用的源是http://localhost,而手机上又没有运行本地服务器,因此解决方案是将认证配置中的redirect_url参数修改为应用的包id。示例: com.package.id://home
完成OAuth页面中的身份验证后,此操作会将您重定向回应用程序
https://stackoverflow.com/questions/66884440
复制相似问题