title: OAuth 2.0 Flow with Firebase Functions
body: <p>How do I use Firebase Functions to successfully connect to an OAuth 2.0 app (ex: <a href="https://alpaca.markets/docs/build-apps_services-with-alpaca/oauth-guide/" rel="nofollow noreferrer">Alpaca</a>)? The closest I've found is this <a href="https://cloud.google.com/community/tutorials/cloud-functions-oauth-gmail" rel="nofollow noreferrer">GCP tutorial</a> but it doesn't save the access token for future use.</p>
  
  <p>How do I:</p>
  
  <ol>
  <li>Remember the state (random string used to protect against request forgery attacks) across different Firestore Functions so I can determine whether it's unchanged?</li>
  <li>Associate the access token with the user that authorized me (ideally saving the token in Firestore)?</li>
  </ol>
  
  <p>Is there a library that does all this for me that will work from a Firebase Function?</p>