Swift 在iOS 11和iOS 12上注销后出现ASWebAuthentication和SFAuthentication登录问题,无法使会话无效
我正在使用Swift 在iOS 11和iOS 12上注销后出现ASWebAuthentication和SFAuthentication登录问题,无法使会话无效,swift,authentication,oauth-2.0,sfauthenticationsession,aswebauthenticationsession,Swift,Authentication,Oauth 2.0,Sfauthenticationsession,Aswebauthenticationsession,我正在使用ASWebAuthentication和SFAuthentication在OAuth2服务器上使用grant\u type:authentication\u code进行身份验证 除了以下各项外,一切都很完美: 用户登录成功 通过注销访问令牌和状态代码为200的刷新令牌注销 测试撤销是否有效 print("Auth-Login : Process: Authenticate user") let state = String().createState(length: 4)
ASWebAuthentication和SFAuthentication
在OAuth2服务器上使用grant\u type:authentication\u code
进行身份验证
除了以下各项外,一切都很完美:
注销访问令牌和状态代码为200的刷新令牌注销
print("Auth-Login : Process: Authenticate user")
let state = String().createState(length: 4)
let codeVerifier = String().createCodeVerifier()
let codeChallenge = codeVerifier.pkceEncode.base64UriEncode
let parameters = ["state=\(state)", "code_challenge=\(codeChallenge)"]
let url = createUrl(parameters: parameters)
guard let authURL = url else { return }
DispatchQueue.main.async {
self.delegate?.removeLoader()
if #available(iOS 12.0, *) {
print("Auth-Login : Process: Run ASWebAuthenticationSession")
self.webAuthSession = ASWebAuthenticationSession(url: authURL, callbackURLScheme: "no.bilkollektivet.app") { (callbackUrl, error) in
print(callbackUrl)
if let error = error {
completionHandler(nil, nil, error)
} else {
let result = self.getCodeFromCallbackUrl(url: callbackUrl, state: state)
completionHandler(result.code, codeVerifier, result.error)
}
}
if #available(iOS 13.0, *) {
self.webAuthSession.presentationContextProvider = self
self.webAuthSession.prefersEphemeralWebBrowserSession = true
}
self.webAuthSession.start()
} else {
print("Auth-Login : Process: Run SFAuthenticationSession")
self.sfAuthSession = SFAuthenticationSession(url: authURL, callbackURLScheme: "no.bilkollektivet.app") { (callbackUrl, error) in
if let error = error {
completionHandler(nil, nil, error)
} else {
let result = self.getCodeFromCallbackUrl(url: callbackUrl, state: state)
completionHandler(result.code, codeVerifier, result.error)
}
}
self.sfAuthSession.start()
}
}