0

Is it possible to use the web storage API in my cloud function? I need to set/get auth token in localStorage for a 3rd party service.

I'm watching for updates to a document, based on the update I need to call a 3rd party service, but the 3rd party service auths with bearer tokens. My question is can I use localStorage to set/get this token?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
its_tayo
  • 1,175
  • 1
  • 12
  • 23

1 Answers1

0

Cloud Functions run on a server, so don't have access to a browser-based localStorage implementation.

If you want to store something on the server, you can write it to the temporary file system. Just be aware that this can disappear at any moment and is not persisted, so you should only use it for caches you can also recalculate.

If you want to store data persistently, you should use a persistent storage layer, typically a cloud based database of some sort (such as Firebase Realtime Database or Firestore).

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807