# Secret in express-open-id

**URL:** <https://community.auth0.com/t/secret-in-express-open-id/74914>\
**Category:** Get Help\
**Created:** [December 14, 2021, 10:59pm UTC](https://community.auth0.com/t/secret-in-express-open-id/74914 "2021-12-14T22:59:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsheff](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nsheff/32/33780_2.png) [@nsheff](https://community.auth0.com/u/nsheff)\
**Post date:** [December 14, 2021, 10:59pm UTC](https://community.auth0.com/t/secret-in-express-open-id/74914/1 "2021-12-14T22:59:41Z")

</div>

- **Which SDK this is regarding:** express-openid-connect

I’m wondering where I can find out more information about the ‘secret’ used by this SDK. In the docs, the examples have a `secret`, which it suggests is a long random string.

```auto
const config = {
  authRequired: false,
  auth0Logout: true,
  baseURL: 'http://localhost:3000',
  clientID: 'YOUR_CLIENT_ID',
  issuerBaseURL: 'https://YOUR_DOMAIN',
  secret: 'LONG_RANDOM_STRING'
};

```

In my tests, I can put whatever I want in there and it doesn’t seem to change behavior. So why doesn’t the software just generate a random string? Do I really need to put this in an environment variable so it persists?

the docs say:

> REQUIRED. The secret(s) used to derive an encryption key for the user identity in a session cookie and to sign the transient cookies used by the login callback. Use a single string key or array of keys for an encrypted session cookie. Can use env key SECRET instead.

[https://auth0.github.io/express-openid-connect/interfaces/configparams.html#secret](https://auth0.github.io/express-openid-connect/interfaces/configparams.html#secret)

What I’m wondering is could I just generate a random string in the code and use that ?  
like, with:

```auto
(Math.random()).toString(24) + (Math.random()).toString(24)

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 16, 2021, 9:37pm UTC](https://community.auth0.com/t/secret-in-express-open-id/74914/3 "2021-12-16T21:37:26Z")

</div>

Hi @nsheff,

Welcome to the Auth0 Community!

This SO thread goes in-depth about this question. Check it out!

> <https://stackoverflow.com/questions/47105436/how-and-when-do-i-generate-a-node-express-cookie-secret/47113162#47113162>

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 31, 2021, 9:37pm UTC](https://community.auth0.com/t/secret-in-express-open-id/74914/4 "2021-12-31T21:37:49Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
