Why would an OAuth implementation choose to use the Authorization Code Grant -- when it means that the access tokens are leaked to a third party?
I've been using API keys for a package on my server to communicate with a service provider's API. I recently updated the package, and they no longer support API keys. They're forcing us to authenticate with OAuth 2.0.
Unfortunately, I learned that they're using the Authorization Code Grant with a static redirect uri, which means the redirect uri must be the devloper's server. As a result, this implementation means that the (non-expiring) access token is first sent to the developer's server (where they claim they don't store it), and then it's passed down to my server (where it is stored).
The service provider is claiming that OAuth is more secure than using API keys, but when I setup the API keys, it was me who generated and set permissions of the key. And it was only my server (and the service provider's server) that ever saw the key.
Of course, using OAuth in this way is less secure, because it violates PoLP. The third party does not need my access token, and exposing it to them is an unnecessary security risk. My best-guess is that the service provider's product team is pushing OAuth for a better UX at the expense of security, and I can only guess they chose the Authorization Code Flow because they had already set it up elsewhere, and it was just easier to (ab)use it in this scenario.
In what situation is an Authorization Code Grant appropriate? When would you want to use the Authorization Code Flow (ie: when would it be beneficial to security)?
And in what situation is an Authorization Code Grant not appropriate? When would you want to avoid using the Authorization Code Flow (ie: when would it be detrimental to security)?