Skip to content

Instantly share code, notes, and snippets.

View nguyentruongky's full-sized avatar
💻
Code for life.

Ky Nguyen nguyentruongky

💻
Code for life.
View GitHub Profile
@cmoulton
cmoulton / BasicAuth.swift
Created June 29, 2016 16:46
Alamofire Basic Auth
func doGetWithBasicAuthCredential() -> Void {
let username = "myUsername"
let password = "myPassword"
let credential = NSURLCredential(user: username, password: password, persistence: NSURLCredentialPersistence.ForSession)
Alamofire.request(.GET, "https://httpbin.org/basic-auth/\(username)/\(password)")
.authenticate(usingCredential: credential)
.responseString { _, _, result in
if let receivedString = result.value