My understanding is that the OAuth Authorization Code Flow is used to avoid exposing the access token from the User Agent. But why?
I was reading this article (Common OAuth Vulnerabilities) by Doyensec.
It says that the Authorization Code Flow is supposed to be used when you don't want to share the tokens with the user agent.
The Authorization Code Flow is one of the most widely used OAuth flows in web applications. Unlike the Implicit Flow, which requests the Access Token directly to the Authorization Server, the Authorization Code Flow introduces an intermediary step. In this process, the User Agent first retrieves an Authorization Code, which the application then exchanges, along with the Client Credentials, for an Access Token. This additional step ensures that only the Client Application has access to the Access Token, preventing the User Agent from ever seeing it.
source: https://blog.doyensec.com/2025/01/30/oauth-common-vulnerabilities.html
Ok, the (non-compartimentalized) User Agent (web browser) is probably the most likely vector of attack these days. The chances of it being compromised are pretty high. It makes sense to me that you wouldn't want to expose secret things to chrome or firefox, if you can avoid it.
But in this case, the user has already entered their account credentials into the User Agent! And the access tokens would only grant the same (or less!) access as the user's main account credentials.
So why bother trying to hide tokens from the User Agent?