I need to implement native authentication with AWS Cognito and I am trying to use https://github.com/adam-fowler/soto-cognito-authentication-kit in my iOS App (client side).
I am struggling with the usage of the CognitoAuthenticatable
object for starting a username/password auth.
Here is my code:
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: "")
}
}
The authenticate
method is supposed to return EventLoopFuture<CognitoAuthenticateResponse>
- How to handle the response of the
authenticate
method? I am getting the errorGeneric parameter 'NewValue' could not be inferred
- How to construct the
CognitoContextData
object. I just want to use the default values for AWS server location.