bolt-python: Cannot listen to the messages posted by users who hasn't installed the app

Hello! I am developing a slack app with python, which should work on user behalf. The event listener should retrieve all the messages, from the workspace’s channels and direct messages that the user, who installed the app, has access to. To achieve that goal I am using Events API with Oauth authorization and user scopes.

Reproducible in:

The slack_bolt version

slack-bolt==1.14.3 slack-sdk==3.18.3 slackeventsapi==3.0.1

Python runtime version

Python 3.8.10

Steps to reproduce:

  1. Here is my Oauth settings and App setup.
oauth_settings = OAuthSettings(
    client_id=os.environ["SLACK_CLIENT_ID"],
    client_secret=os.environ["SLACK_CLIENT_SECRET"],
    user_scopes=user_scopes,
    installation_store=FileInstallationStore(base_dir="./data/installations"),
    state_store=FileOAuthStateStore(expiration_seconds=600, base_dir="./data/states")
)

app = App(signing_secret=os.environ["SLACK_SIGNING_SECRET"], oauth_settings=oauth_settings)

api = FastAPI()
app_handler = SlackRequestHandler(app)
  1. You can see that I am using FastAPI to handle the requests. Here is the FastAPI setup.
@api.get("/slack/oauth_redirect")
async def oauth_redirect(req: Request):
    await app_handler.handle(req)
    return logging.info('Installation completed.')


@api.get("/slack/install")
async def install(req: Request):
    return await app_handler.handle(req)


@api.post("/slack/events")
async def endpoint(req: Request):
    return await app_handler.handle(req)
  1. And this is the example test event listener function, that should just print out in the console the payload of the message.
@app.event('message')
def listener(payload, client):
    print(payload)

Expected result:

I am expecting to see every message’s payload in the console posted in all the channels and direct messages, where the user is added (in this stage I am the user who installed the app to the workspace, also I am the admin of the workspace where the app is installed to).

Actual result:

Every time that the message is posted by a user, who hasn’t installed the app, I am getting this message in my console: Screenshot from 2022-09-23 14-45-53

Thanks in advance!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (5 by maintainers)

Most upvoted comments

@seratch @hello-ashleyintech Thank you very much guys!

thank you very much. only FastAPI.