Last active
September 14, 2018 17:38
-
-
Save seanbehan/18763d140d9bcbe3411a960d856bcfb1 to your computer and use it in GitHub Desktop.
basic auth with alamofire in 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
import Alamofire | |
let url = "https://example.com/" | |
let user = "me" | |
let pass = "pwd" | |
let headers: HTTPHeaders = [ | |
"Authorization": "Basic " + ("\(user):\(pass)".data(using:.utf8)?.base64EncodedString() ?? ""), | |
] | |
Alamofire.request(url, headers: headers).responseJSON { response in | |
debugPrint(response) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment