I'm using Alamofire
to do a simple request
Alamofire.request(.GET, URL)
.authenticate(user: user, password: password)
.responseJSON { response in
...
}
After a first valid request, I changed the credential with invalid ones and the request succeed, but it should fail.
How can I invalidate previous credentials?
After a successful request, if I change the credential, Alamofire
authenticates the previous credential.
How can I invalidate previous credentials?
Adding Authorization header helped me.
let user = "user"
let password = "password"
let credentialData = "\(user):\(password)".dataUsingEncoding(NSUTF8StringEncoding)!
let base64Credentials = credentialData.base64EncodedStringWithOptions([])
let headers = ["Authorization": "Basic \(base64Credentials)"]
Alamofire.request(.GET, "https://httpbin.org/basic-auth/user/password", headers: headers)
.responseJSON { response in
debugPrint(response)
}