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.

Document using OAuth with an instance of ExpressReceiver

See original GitHub issue

Description

Original reference: https://github.com/slackapi/bolt-js/pull/711#issuecomment-745693232

A common use-case that we’ve experienced is that developers needing to use OAuth with an instance of ExpressReceiver. This may happen because the developer is extending the receiver, such as adding custom routes.

Our current OAuth documentation explains how to set up OAuth using the App constructor. But it doesn’t explain how to set up OAuth using an instance of ExpressReceiver.

I’ve created this issue rather than making the update in pull https://github.com/slackapi/bolt-js/pull/711 because it’s not immediately clear where we should document this. We will want to use a new code example (see below) and that will require a new documentation section.

  • Do we want to create a subsection under the current Basic Concepts - Authenticating with OAuth?
  • Or, do we want to create an ExpressReceiver section and ExpressReceiver - Authenticating with OAuth subsection?
  • Or, something else?
  • How does this impact Bolt for Python documentation?

Code example for using OAuth with an instance of ExpressReceiver:

const customReceiver = new ExpressReceiver({
  signingSecret: process.env.SLACK_SIGNING_SECRET,
  clientId: process.env.SLACK_CLIENT_ID,
  clientSecret: process.env.SLACK_CLIENT_SECRET,
  stateSecret: 'my-state-secret',
  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);
    },
    storeOrgInstallation: async (installation) => {
      // include this method if you want your app to support org wide installations
      // change the line below so it saves to your database
      return await database.set(installation.enterprise.id, installation);
    },
    fetchOrgInstallation: async (InstallQuery) => {
      // include this method if you want your app to support org wide installations
      // change the line below so it fetches from your database
      return await database.get(InstallQuery.enterpriseId);
    },
  },
})

const app = new App({
  receiver: customReceiver
});

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:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
stevengillcommented, Dec 18, 2020

Maybe we just add an example app for this instead of adding a section to the docs?

1reaction
seratchcommented, Mar 5, 2021

@mwbrooks I just wanted to check the current status of this. Are we going to add an example OAuth app under examples directory sometime in the future?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Slack Bot with Bolt for JavaScript and OAuth 2.0 to share the ...
it had to be const expressReceiver = new ExpressReceiver({ signingSecret: process.env.SLACK_SIGNING_SECRET, endpoints: "/slack/events" });.
Read more >
Migrating to v3.x - Slack | Bolt for JavaScript
This guide will walk you through the process of updating your app from ... used during OAuth, fetchOrgInstallation & storeOrgInstallation .
Read more >
Using OAuth 2.0 - Google
This document discusses how to obtain and use OAuth 2.0 credentials using the Google APIs Client Library for C++. It provides a high...
Read more >
How to use the @slack/bolt.ExpressReceiver function in ...
To help you get started, we've selected a few @slack/bolt.ExpressReceiver examples, based on popular ways it is used in public projects.
Read more >
Bolt @slack_bolt@3.11.0 Release - GitClear
Fix #1335 Proper use of state parameter for the OAuth CSRF protection (#1391). Authored March 28, 2022. More ExpressReceiver tests (#1407).
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