For you to connect OAuth 2.0 to Cloud Functions, indeed, the documentation you provided, would be the official one, to achieve that. And I understand your points, about your questions, of remembering state and associating the token with the access, it actually would be very helpful.
To answer your question, there isn't a library that does all of this for you. Searching around, it seems that you can use a JWT token, which would provide you some options of predefined fields, that might help you have more control to the expiration time, who the token is intended to, etc. In case you are interested on it, there is a good documentation about how to use it with Cloud Functions here: Understanding OAuth2 and Deploying a Basic Authorization Service to Cloud Functions
Outside of that, unfortunately, it doesn't seem that you have other options. For this reason, I would recommend you also to raise a Feature Request in Google's Issue Tracker, so they can take a look about the possibility of changing/improving the way that the OAuth 2.0 works with Cloud Functions in the future.
Let me know if the information helped you!