我需要使用 AWS Cognito 实施本机身份验证,并且我正在尝试在我的 iOS 应用程序(客户端)中使用https://github.com/adam-fowler/soto-cognito-authentication-kit 。
我正在努力使用该CognitoAuthenticatable
对象来启动用户名/密码身份验证。
这是我的代码:
class LoginHandler {
func handleLogin(username: String, password: String) {
var eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let data = AWSCognitoContext()
let response = self.authenticatable.authenticate(
username: username,
password: password,
requireAuthenticatedClient: false,
clientMetadata: nil,
context: data,
on: eventLoopGroup.next()
)
response.flatMap { response in
// use response object
}
}
}
class AWSCognitoContext: CognitoContextData {
var contextData: CognitoIdentityProvider.ContextDataType? {
return CognitoIdentityProvider.ContextDataType(
httpHeaders: [],
ipAddress: "",
serverName: "",
serverPath: "")
}
}
该authenticate
方法应该返回EventLoopFuture<CognitoAuthenticateResponse>
- 如何处理
authenticate
方法的响应?我收到错误Generic parameter 'NewValue' could not be inferred
- 如何构造
CognitoContextData
对象。我只想使用 AWS 服务器位置的默认值。