Next.js Discord

Discord Forum

What is the `state` parameter for the authorization code flow OAuth?

Unanswered
German Longhaired Pointer posted this in #help-forum
Open in Discord
German Longhaired PointerOP
One of the parameters in the API is called state and am unsure on what it's for and what it does even after reading its description. On the API, it reads as:
A semi-random data blob to send back with when completing authorization.

I tried looking up what this meant online and found [this link](https://developers.google.com/identity/protocols/oauth2/web-server). Should I just have an arbitrary set of characters in my .env file and use this as value for the state parameter? Something like:
console.log(require('crypto').randomBytes(32).toString('hex'))

and use this value for the .env?

0 Replies