Last active
November 21, 2017 13:53
-
-
Save romanmiller/844ec75b34f6408ddbf894d1b2413218 to your computer and use it in GitHub Desktop.
Encoding String to set Auth Token (LogIn Credentials Example) (Swift)
This file contains hidden or 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
open static func setAuthToken(_ email:String, password: String) -> [String: String] { | |
let credentialData = "\(email):\(password)".data(using: String.Encoding.utf8)! | |
let base64Credentials = credentialData.base64EncodedString(options: []) | |
let token = "Basic \(base64Credentials)" | |
return ["Authorization": token] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment