簡體   English   中英

無法使用 MSAL 對 iOS Swift4.2 進行身份驗證

[英]Unable to authenticate using MSAL for iOS Swift4.2

我無法執行 MSAL SDK。 我遇到了下面提到的問題......我已經解決了許多 StackOverflow 問題,但仍然無法解決這個問題。

問題:

qwerty[66144:4049892] -canOpenURL: failed for URL: "msauthv2://broker" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
qwerty[66144:4052892] Failed to query AuthBrokerAgent Task <49DC4AA3-FAC7-4268-94DA-41FE68FD584F>.<1>
qwerty[66144:4052892] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = htsx;
    "r_Attributes" = 1;
    srvr = "intpxy1.ind.mobi";
    sync = syna;
}
qwerty[66144:4052492] Failed to get applicable proxy auth Task <49DC4AA3-FAC7-4268-94DA-41FE68FD584F>.<1>
qwerty[66144:4050495] Task <49DC4AA3-FAC7-4268-94DA-41FE68FD584F>.<1> HTTP load failed (error code: 311 [4:-2097])
qwerty[66144:4052491] Task <49DC4AA3-FAC7-4268-94DA-41FE68FD584F>.<1> finished with error - code: 311
App error: Error Domain=kCFErrorDomainCFNetwork Code=311 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2097, _kCFStreamErrorDomainKey=4}
qwerty[66144:4052495] Received XPC error Connection interrupted for message type 3 kCFNetworkAgentXPCMessageTypePACQuery
qwerty[66144:4052495] Received XPC error Connection invalid for message type 3 kCFNetworkAgentXPCMessageTypePACQuery

我的系統配置:

  • Mac 操作系統:macOS High Sierra
  • XCode 版本:版本 10.1 (10B61)

請幫我。

請檢查以下所有內容是否到位:kClientID、kAuthority、LSApplicationQueriesSchemes。 還要確保您有一個有效的 Microsoft 帳戶。 我最近集成了 Microsoft 登錄,如下所示。

func initMSAL() throws {
        guard let authorityURL = URL(string: kAuthority) else {
            return
        }
        let authority = try MSALAADAuthority(url: authorityURL)
        let msalConfiguration = MSALPublicClientApplicationConfig(clientId:kClientID, redirectUri: nil, authority: authority)
        self.applicationContext = try MSALPublicClientApplication(configuration: msalConfiguration)
    }


    func loginUser(completion:@escaping((Bool) -> Void)) {
        guard let applicationContext = self.applicationContext else { return }
        let parameters = MSALInteractiveTokenParameters.init(scopes: kScopes, webviewParameters: MSALWebviewParameters(parentViewController: (UIApplication.shared.windows.last?.rootViewController)!))
        parameters.promptType = .selectAccount
        applicationContext.acquireToken(with: parameters) { (result, error) in
            if let error = error {
                print("Could not acquire token: \(error)")
                return
            }

            guard let result = result else {
                print("Could not acquire token: No result returned")
                return
            }
            print("Access Token is:", result.accessToken)
            
            completion(true)
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM