(Swift) qa.factura1.com.co Obtain Auth Token
Demonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.co Note: This example requires Chilkat v11.0.0 or greater.
func chilkatTest() {
var success: Bool = false
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
// Build the following JSON
// {
// "password": "MY_PASSWORD",
// "username": "MY_USERNAME"
// }
let json = CkoJsonObject()!
json.emitCompact = false
json.update("password", value: "MY_PASSWORD")
json.update("username", value: "MY_USERNAME")
let resp = CkoHttpResponse()!
success = http.httpJson("POST", url: "https://qa.factura1.com.co/v2/auth", json: json, contentType: "application/json", response: resp)
if success == false {
print("\(http.lastErrorText!)")
return
}
let jsonResp = CkoJsonObject()!
jsonResp.emitCompact = false
jsonResp.load(resp.bodyStr)
print("\(jsonResp.emit()!)")
print("Access token: \(jsonResp.string(of: "token")!)")
}
|