What's the standard best-practice approach for coordinating the browser/user agent session with the client in the OAuth 2.0 Authorization Code Flow?
In the OAuth 2.0 Authorization Code Flow, the client (Web application you are using) gets an access token directly from the Authorization Server. The access token is never exposed to browser/user agent, one of the important benefits of Code Flow. The client security preserves the access token (and refresh token, if provided) so that it can reuse it for subsequent requests from the user (via the browser/user agent.)
That leads to a question: How do the client and the browser/user agent convey the user's session, so that the client "knows" which access token to use on behalf of the user, and that it's okay to do so?
I've found sample code in which the client creates a session cookie for the browser/user agent. That works, but seems to reopen the door to cookie-based exploits. There are standard approaches to prevent them, but I thought that one benefit of OAuth 2.0 is to avoid those attacks altogether. (Besides, we're hosting a Web REST API, so there are no forms to POST, and I'd like to keep the API interface clean, simple, and based on standard security approaches.)
Notes:
The OAuth's tokens and sessions in REST doesn't actually answer this particular question, although I, too, love Greg Beech's response.
The question Understanding OAuth and client sessions has a similar intent, but the answer does not apply to our case.
This question is about subsequent requests from the user agent, not about the callback handler.
We fully expect and intend that our REST requests will not be stateless, and that client-side will maintain state information for the user's session. For very good reasons that I would rather not enumerate here, we are not making a stateless REST interface.