Skip to content

Instantly share code, notes, and snippets.

@ali-cs
Created September 10, 2019 11:06
Show Gist options
  • Save ali-cs/05697f90647a5db81b408fcb9d4fb33d to your computer and use it in GitHub Desktop.
Save ali-cs/05697f90647a5db81b408fcb9d4fb33d to your computer and use it in GitHub Desktop.
CredentialIdentityAuthenticationProvider
class CredentialIdentityAuthenticationProvider : AWSCognitoCredentialsProviderHelper {
override func token() -> AWSTask<NSString> {
//Write code to call your backend:
//pass username/password to backend or some sort of token to authenticate user, if successful,
//from backend call getOpenIdTokenForDeveloperIdentity with logins map containing "your.provider.name":"enduser.username"
//return the identity id and token to client
//You can use AWSTaskCompletionSource to do this asynchronously
// Set the identity id and return the token
self.identityId = MqttConstants.mqttCognitoKey
let value = MqttConstants.clientSecret
return AWSTask(result: value as NSString)
}
override func logins() -> AWSTask<NSDictionary> {
let key = MqttConstants.mqttCognitoKey
let value = MqttConstants.clientSecret
let dictionary = NSDictionary(dictionary: [key:value])
return AWSTask(result: dictionary)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment