Last active
October 14, 2020 10:10
-
-
Save aalemi97/8c1c1721536025e387a5d665f0654974 to your computer and use it in GitHub Desktop.
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
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