Just to let everyone know, after I was able to obtain the OAUTH bearer token, I then faced an Authentication Failed error while trying to use that token to send SMTP emails using client credentials flow.
It turns out that my Azure server had not been fully configured with all the permissions needed to send the emails.
The last steps described here-> https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth#register-service-principals-in-exchange to create the service principal and give it permissions to the target mailbox had not been done.
Once this was completed, I was able to send SMTP emails through javamail successfully.