I'm setting up a system that automatically connects to a Microsoft email account using IMAP and OAuth2. This system continuously monitors the mailbox, and upon receiving a new email, it triggers a secondary process that is not relevant here. In Microsoft, the OAuth configuration allows me to make the connection in a non-interactive manner (it's required to be non-interactive) using the "client_credentials" flow. This works without any issues.
For a Google account with basic authentication, it also works fine. However, Google will eventually discontinue basic authentication access to IMAP. My specific problem is how to configure the connection to Google using OAuth and client-credentials. If I adjust the configuration I already have to fit Google, it throws the following error:
{ "error": "unsupported_grant_type", "error_description": "Invalid grant_type: client_credentials" }
Credentials were created in the Google Developers Console, first as a web app and then as a desktop application. In both cases, it didn't work, always showing the same error. Is it possible to achieve what I'm proposing? If so, how do I configure my system?
This is a test application that i use to test this cases
Any suggestions would be appreciated. Thanks in advance
I change client type from developer console to web application and to desktop






