Created
September 10, 2019 11:06
-
-
Save ali-cs/05697f90647a5db81b408fcb9d4fb33d to your computer and use it in GitHub Desktop.
CredentialIdentityAuthenticationProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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