我正尝试在 iOS 应用程序中使用 Azure B2C 对用户进行身份验证。我正在关注此处提供的示例: https://github.com/Azure-Samples/active-directory-b2c-ios-swift-native-msal
我可以获取 token ,但是当我尝试调用 protected Web 服务时,出现 401 错误。当我使用 PostMan 并获取 token ,然后将其复制到应用程序时,它可以正常工作。
看起来用于获取 token 的 Urls 是不同的——这个在 PostMan 中有效: https://{orgname}.b2clogin.com/tfp/{tenant}/oauth2/v2.0/authorize?p={policy}
在 iOS 示例中,此 url 似乎是 MSAL 中的默认设置: https://login.microsoftonline.com/tfp/ {租户}/{政策}
我尝试将 kAuthority 变量更新为适用于 PostMan 的 Url,但这会导致错误:
▿ 可选 - 一些:错误域=MSALErrorDomain 代码=-42002“(空)”UserInfo={MSALErrorDescriptionKey=此类权限不支持权限验证}
有人知道新 b2clogin.com url 的 MSAL 库的正确配置吗?
最佳答案
If you're using MSAL, set the ValidateAuthority property to false. When ValidateAuthority is set to false, redirects are allowed to b2clogin.com.
因此您需要禁用权限验证才能使用 b2clogin.com URL。
关于ios - MSAL 从 iOS Swift 示例返回错误 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56794600/