Digest Authentication with Alamofire 5.2

Hello all,
I am relatively new to Swift programming and I'm having trouble understanding how to use Alamofire 5.2 with Digest Authentication specifically using a POST command.
The GET code is quite simple, since one can just add the credential in an authenticate to modify the request on retry. So this works fine:

let user = client_id let password = client_secret let credential = URLCredential(user: user, password: password, persistence: .forSession)
    AF.request(queues)
        .authenticate(with: credential)
        .responseJSON { response in
           debugPrint(response)
              switch response.result {
             case let .success(result):
                 self.presentAlert(title: "Data", message: "Message: \n\n \(result)")
             case let .failure(error):
                 self.presentAlert(title: "Error", message: error.localizedDescription)
             }
    }

But this is only for a GET request. If I change a request to something like this:

let request = AF.request(
Endpoint.POST.url(),
method: Endpoint.POST.httpMethod,
parameters: userStruct,
encoder: JSONParameterEncoder.default
)

there is not such .authenticate for me to use. In the Basic Authentication construct one can just add it to the header but I'm not aware that I can do this with Digest Auth.

It feels like I should be using a more advanced AF feature/function like RequestInterceptor or RequestModifier but despite having read about them, can't wrap my head around the syntax for what I need to do with my code.

Any advice and especially code specific examples would really help?

Thanks in advance should such help come my way.
Doug

I'm not sure what you're seeing, but authenticate is available on all Requests, just like in your original example. Using the authenticate(username:password:) method will even create and attach the appropriate URLCredential for you. From Alamofire's (and URLSession's) perspective, there's no difference between Basic and Digest authentication, it's all handled automatically underneath URLSession.

First thank you for the quick reply, I really appreciate it. So here is the code from my above example isn't working:

let request = AF.request(
Endpoint.POST.url(url: urlString),
method: Endpoint.POST.httpMethod,
parameters: userStruct,
encoder: JSONParameterEncoder.default,
authenticate: (username: password)
)

With such a construct the Error message is "Extra argument 'authenticate' in call"
It seems I am missing something easy, and it needs to be passed elsewhere?

Yes, authenticate is not a parameter of the request method but, like your first example, a chained method that comes after the request call.

AF.request(Endpoint.POST.url(url: urlString),
           method: Endpoint.POST.httpMethod,
           parameters: userStruct,
           encoder: JSONParameterEncoder.default)
    .authenticate(username: ..., password: ...)

Again thanks for such a quick reply. It worked (that is to say, compiled) and now I'm off to dive down into my code hole to find how to fill my POST body and get on with sending the request and interpreting the response. You have my undying thanks for your responsive help sir!