question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Where to find stateSecret value

See original GitHub issue

Description

Hi everyone šŸ‘‹ First off, love Bolt - great job!

I’m following along with implementing oAuth for Bolt using the docs and have implemented the following - my issue is I can’t find how to get the correct value for stateSecret?

How do you get this value to complete the oAuth flow so you’re able to authenticate and distribute your app?

const app = new App({
  signingSecret: process.env.SLACK_SIGNING_SECRET,
  clientId: process.env.SLACK_CLIENT_ID,
  clientSecret: process.env.SLACK_CLIENT_SECRET,
  stateSecret: 'my-state-secret', // where to find this value?
  scopes: ['channels:read', 'groups:read', 'channels:manage', 'chat:write', 'incoming-webhook'],
  installationStore: {
    storeInstallation: async (installation) => {
      // change the line below so it saves to your database
      return await database.set(installation.team.id, installation);
    },
    fetchInstallation: async (InstallQuery) => {
      // change the line below so it fetches from your database
      return await database.get(InstallQuery.teamId);
    },
  },
});

Sorry if this is obvious, I’ve tried searching the docs and feel I’m missing something right in my face.

If I understand correctly, once the user is redirected via http://api.mydomain.com/slack/oauth_redirect - this include the stateSecret? But how would I pass that value before the app is initalised? I’m not sure what I’m missing.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
  • I’ve read and agree to the Code of Conduct.
  • I’ve searched for any related issues and avoided creating a duplicate issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
stevengillcommented, Dec 3, 2020

Hey @alexjackhughes!

Glad to hear you are loving bolt!

stateSecret is something you come up with. Any random string. It is just to encode/decode the state when going through the OAuth flow. It will encode it when generating the Add to Slack url. Then when your redirect url is hit (http://api.mydomain.com/slack/oauth_redirect), it will receive a payload from slack that returns the state value (which was the encoded one we passed when installing. The stateSecret will be used here to decode and verify state wasn’t tampered with by bad actors.

Let me know if you have any follow up questions! If not, can you close the issue šŸ˜„

1reaction
seratchcommented, Jan 11, 2022

Hi @anthonygualandri,

Is there a reason that the stateSecret isn’t an env variable?

This is a really good point. The document should encourage people to use an env variable for it too.

Is the stateSecret supposed to be generated randomly each time the app install process is called and so should be generated in the code itself every time?

No, it isn’t but we know that some people may want to do so (see also: https://github.com/slackapi/bolt-js/issues/1205#issuecomment-966723613) We may enhance this part in future releases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OAuth - Slack Platform Developer Tools
This SDK is a collection of single-purpose packages. The packages are aimed at making building Slack apps easy, performant, secure, and scalable.
Read more >
<activity> | Android Developers
When the value is " false ", the task may be cleared of activities in some situations (see the alwaysRetainTaskState attribute), but not...
Read more >
definition of State secret by The Free Dictionary
Official information that has been determined to require, in the interests of national security, protection against unauthorized disclosure and which has beenĀ ...
Read more >
LAW - on State Secret - Refworld
(1) The present Law sets the legal framework for state secret protection ... e) operations related to producing monetary signs and state value...
Read more >
Government Warehousing of DNA a Disturbing State Secret ...
ā€œWhile there is little disagreement over the value of newborn screening, what happens after the screening is causing a contentious debate nationwide,ā€ CCHFĀ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found