1

我正在尝试使用这个库(AppAuth-iOS)通过 Forgerock 使用 OpenID 身份验证 2.0 进行身份验证。

当我运行此示例应用程序时,选择“自动授权”我设法在 Forgerock 中对用户进行身份验证,但随后出现以下错误:

在此处输入图像描述

查看调试错误,它显示以下内容:

错误域=org.openid.appauth.general 代码=-4 \"(null)\"

这是它被调用的方法(信用:从我上面链接的应用程序示例代码中获取的方法):

@IBAction func authWithAutoCodeExchange(_ sender: Any) {

    let issuer = URL(string: kIssuer)
    let redirectURI = URL(string: kRedirectURI)

    logMessage(format: "Fetching configuration for issuer: %@", issuer!.absoluteString)

    // discovers endpoints
    OIDAuthorizationService.discoverConfiguration(forIssuer: issuer!, completion: { (config, error) in
        if config == nil {
            self.logMessage(format: "Error retrieving discovery document: %@", error!.localizedDescription)
            self.authState = nil
            return
        }

        self.logMessage(format: "Got configuration: %@", config!.description)

        // builds authentication request
        let request = OIDAuthorizationRequest(configuration: config!, clientId: kClientID, scopes: [OIDScopeOpenID], redirectURL: redirectURI!, responseType: OIDResponseTypeCode, additionalParameters: nil)

        // performs authentication request
        let appDelegate = UIApplication.shared.delegate as! AppDelegate
        self.logMessage(format: "Initiating authorization request with scope: %@", request.scope!)
        appDelegate.currentAuthFlow = OIDAuthState.authState(byPresenting: request, presenting: self, callback: { (authState, error) in
            if authState != nil {
                self.authState = authState
                self.logMessage(format: "Got authorization tokens. Access token: %@", (authState?.lastTokenResponse?.accessToken)!)
            } else {
                self.authState = nil
                self.logMessage(format: "Authorization error: %@", error!.localizedDescription)
            }
        })
    })

}

关于这是客户端错误还是 Forgerock 端配置错误的任何想法?

4

0 回答 0