I send the following request:

in fact, in the values ​​of consumerKey and consumerSecret I transfer data from my dev.twitter.com account

let consumerKey = "myConsumerKey" let consumerSecret = "myConsumerSecret" let credentialsString = "\(consumerKey):\(consumerSecret)" let credentialsData = (credentialsString as NSString).dataUsingEncoding(NSUTF8StringEncoding) let base64String = credentialsData!.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0)) let headers = ["Authorization": "Basic \(base64String)"] let params: [String : AnyObject] = ["grant_type": "client_credentials"] Alamofire.request(.POST, "https://api.twitter.com/oauth2/token", headers: headers, parameters: params) .responseJSON { response in switch response.result { case .Success(let JSON): // print("Success with JSON: \(JSON)") let response = JSON as! NSDictionary let userModel = response print("----------------") print("") print("userModel from TW") print(userModel) print("") print("----------------") //dispatch_async(dispatch_get_main_queue(), { //}) case .Failure(let error): print("Request failed with error: \(error)") } } 

In response, I get:

 { errors = ( { code = 99; label = "authenticity_token_error"; message = "Unable to verify your credentials"; } ); } 

What am I doing wrong?

0