Skip to content

Instantly share code, notes, and snippets.

@aalemi97
Last active October 14, 2020 10:10
Show Gist options
  • Save aalemi97/8c1c1721536025e387a5d665f0654974 to your computer and use it in GitHub Desktop.
Save aalemi97/8c1c1721536025e387a5d665f0654974 to your computer and use it in GitHub Desktop.
func login(apiKey: String, secretKey: String) {
let parameters = ["grant_type": "client_credentials", "client_id": apiKey, "client_secret": secretKey]
NetworkManager.shared.authorize(parameters: parameters) { (result) in
switch result {
case .success(let data):
if let token = (try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any])?["access_token"] as? String {
UserDefaultsManager.shared.signIn(apiKey: apiKey, secretKey: secretKey, token: token)
}
case .failure(let error):
print(error)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment