Cannot read property "token" of undefined when using new Bolt auth
See original GitHub issueDescription
I am using the new standard Bolt auth process on bolt version "^2.1.1"
to distribute my app, here is my code:
const app = new App({
signingSecret: config.slack.signingSecret,
clientId: config.slack.clientId,
clientSecret: config.slack.clientSecret,
stateSecret: "a-very-cool-secret",
scopes: ["incoming-webhook", "commands"],
installationStore: {
storeInstallation: (installation) => {
return db.collection("auth").doc(installation.team.id).set(installation);
},
fetchInstallation: (InstallQuery) => {
return db.collection("auth").doc(InstallQuery.teamId);
},
},
but am getting the following error when trying to hit the app_home_opened
event:
[WARN] bolt-app Authorization of incoming event did not succeed. No listeners will be called.
{ Error: Cannot read property 'token' of undefined
at new AuthorizationError (src/node_modules/@slack/oauth/dist/errors.js:70:28)
at InstallProvider.<anonymous> (src/node_modules/@slack/oauth/dist/index.js:114:31)
at step (src/node_modules/@slack/oauth/dist/index.js:33:23)
at Object.next (src/node_modules/@slack/oauth/dist/index.js:14:53)
at fulfilled (src/node_modules/@slack/oauth/dist/index.js:5:58)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 'slack_oauth_installer_authorization_error' }
This is on my dev workspace where I was previously passing in a token
argument to my App constructor. I am getting a 404 when hitting the “Add App to Slack” button after passing it the /slack/oauth_redirect
endpoint and I assume that is why.
I have two misunderstandings that might be creating this issue:
- How do I generate/where do I get the stateSecret? It seems like it’s just a random string I can make up that is used in the hashing of secrets but I am not certain.
- Shouldn’t the
fetchInstallation
be asynchronous? Any DB call would return a Promise, so should we actually return a Promise (as I’m doing here) or the actual document?
What type of issue is this? (place an x
in one of the [ ]
)
- bug
- enhancement (feature request)
- [x ] question
- documentation 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:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'token' of undefined
It looks like the error comes from these lines app.use(function(req, res, next) { console.log(req.headers['x-access-token']); var token ...
Read more >App interface and configuration - Slack | Bolt for JavaScript
This guide is intended to detail the Bolt interface–including listeners and their arguments, initialization options, and errors. It may be helpful to first ......
Read more >Error codes and messages - Adyen Docs
Cause: There is a signature mismatch, the signature cannot be read. 5_208 - PayWithGoogle token already expired. Cause: The token expired. Troubleshoot with ......
Read more >Cannot read property 'scope' of undefined - Using Refresh ...
Please include the following information in your post: ... The issue is changing to refresh token rotation for SPA. I was using the...
Read more >Okta throwing "Cannot read property 'token' of undefined ...
Hi there! I'm using okta sign in widget code in my react app. Login part is quite okay its working as expected, but...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @stevengill! that’s helpful, I’ll make my two functions asynchronous. And sorry, should have specified. I’m using version
"^2.1.1"
, updating the original post to reflect that. Let me try again with the newest version.sounds good, thanks!