I cannot enter my application that uses Oath-2 and receives an unsupported_grant_type error. I use Alamofire to log in to the POST system, but cannot succeed. Where am I doing wrong? I can not solve the problem problem.
func sendFeedback ()
func sendFeedback(){
let parameters = [
"UserName": username_textfield.text! as String,
"Password": password_textfield.text! as String,
"grant_type": "Password" as String,
]
Alamofire.upload(multipartFormData: { multipartFormData in
for (key, value) in parameters {
multipartFormData.append((value.data(using: .utf8))!, withName: key)
}}, to: "http://192.168.100.5:84/Token", method: .post, headers: ["Authorization": "auth_token"],
encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.response { [weak self] response in
guard self != nil else {
return
}
debugPrint(response)
self?.view.makeToast(message: "Send Successfull. !!!")
}
upload.uploadProgress(queue: DispatchQueue(label: "uploadQueue"), closure: { (progress) in
})
case .failure(let encodingError):
print("errorss:\(encodingError)")
}
})
}
I get a 400 status code. How to solve this problem?
source
share