【发布时间】:2021-05-10 08:20:36
【问题描述】:
我需要使用 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 服务器位置的默认值。
【问题讨论】:
标签: ios amazon-cognito soto