Skip to content

Instantly share code, notes, and snippets.

@mgwedd
Created July 16, 2019 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgwedd/4519539f978c66d1b7c4e9851f7aad75 to your computer and use it in GitHub Desktop.
Save mgwedd/4519539f978c66d1b7c4e9851f7aad75 to your computer and use it in GitHub Desktop.
func getAWSClientID(completion: @escaping (_ clientId: String?,_ error: Error? ) -> Void) {
// Depending on your scope you may still have access to the original credentials var
let credentials = AWSCognitoCredentialsProvider(regionType:.EUWest1, identityPoolId: "your-identity-pool-id")
credentials.getIdentityId().continueWith(block: { (task:AWSTask<NSString>) -> Any? in
if let error = task.error as NSError? {
print("Failed to get client ID => \(error)")
completion(nil, error)
return nil // Required by AWSTask closure
}
let clientId = task.result! as String
print("Got client ID => \(clientId)")
completion(clientId, nil)
return nil // Required by AWSTask closure
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment