MSAL 和 IOS - 无法确定我的 B2C 实例的权限



我创建了一个名为myB2CDemonstration的B2C实例,并在其中创建了一个名为B2C_1A-SIGNUP_SIGNIN的体验框架流程。

我的代码是这样的:

let kClientID = "d7628 ... 4a34d"
let kGraphEndpoint = "https://graph.microsoft.com/"
let kAuthority1 = "https://login.microsoftonline.com/7fb6a ... 427"
let kAuthority2 = "https://myB2CDemonstration.b2clogin.com/myB2CDemonstration.onmicrosoft.com/B2C_1A_SIGNUP_SIGNIN"
let kAuthority3 = "https://myB2CDemonstration.onmicrosoft.com/7fb6a ... 427"
let kRedirectUri = "msauth.br.com.edenred.ticket://auth"
let kAuthority = kAuthority1 // or 2 or 3
guard let authorityURL = URL(string: kAuthority) else {
self.updateLogging(text: "Unable to create authority URL")
return
}

let authority = try MSALAADAuthority(url: authorityURL)

let msalConfiguration = MSALPublicClientApplicationConfig(clientId: kClientID,
redirectUri: kRedirectUri,
authority: authority)
msalConfiguration.knownAuthorities = [authority]
self.applicationContext = try MSALPublicClientApplication(configuration: msalConfiguration)
self.initWebViewParams()

如果我使用kAuthority1kAuthority2,我得到错误

Could not acquire token: ErrorDomain =MSALErrorDomain Code=-50000UserInfo={msalerrordescriptionkey =AADSTS50049:未知或无效实例。MSALOAutherrorKey = invalid_instance MSALInternalErrorCOdeKey = -42010}(以及一堆跟踪id,如相关id等)

如果我使用kAuthority3,我得到错误

操作无法完成。(MSIDErrorDomain错误-51112.)TID=3929455 MSAL 1.2.5 iOS Sim 16.2 [2023-01-05 20:48:01] Creating Error with description: Trying initialize AAD authority with B2C authority url.

谁能告诉我我做错了什么?

试试这里的示例,您似乎正在使用AAD示例。https://learn.microsoft.com/en-us/azure/active-directory-b2c/configure-authentication-sample-ios-app

我实际上自己得到了它:我将MSALAADAuthority更改为MSALB2CAuthority,并删除了作用域,并使用了变体2(带有租户名称而没有guid)

最新更新