Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting slack_bolt.AsyncMultiTeamsAuthorization error after user installs the slack app #1257

Open
X0R0X opened this issue Mar 1, 2025 · 1 comment
Labels
question Further information is requested

Comments

@X0R0X
Copy link

X0R0X commented Mar 1, 2025

Hello, I am using GCP Virtual Server for hosting, docker (compose) for deployment. I currently use ngrok to tunnel traffic to the slack server.
I use (also, currently) FileInstallationStore to persist the user installation. When I install the app via /slack/install, everything seems fine - no exception is being thrown. However when i receive /slack/events, i got this error:
Although the app should be installed into this workspace, the AuthorizeResult (returned value from authorize) for it was not found.

The problem is that user installation never gets persisted to the file, my ./data/installations directory is empty, although ./data/states is not. The thing is, when I was running this locally (not on GCP VM), everything worked fine.

My Slack App setup is:

        self._slack_server = AsyncApp(
            logger=slack_server_logger,
            token=slack_bot_token,
            signing_secret=slack_bot_sign_secret,
            oauth_settings=AsyncOAuthSettings(
                client_id=slack_bot_client_id,
                client_secret=slack_bot_client_secret,
                scopes=[
                    "chat:write",
                    "channels:read",
                    "channels:history",
                    "channels:join",
                    "groups:read",
                    "im:history",
                    "im:read",
                    "im:write",
                    "channels:read",
                    "users:read",                  
                ],

                user_scopes=[
                    "im:history",
                    "im:read",
                    "im:write",
                    "mpim:history",
                    "mpim:read",
                    "mpim:write",
                    "channels:read",
                    "channels:write",
                    "channels:history",
                    "users:read",
                    "chat:write",
                    "groups:history",
                    "groups:write",
                    "groups:read",
                    "reactions:read"
                ],
                # todo PG / Redis ...
                installation_store=FileInstallationStore(
                    base_dir="./data/installations"
                ),
                state_store=FileOAuthStateStore(
                    expiration_seconds=3600, base_dir="./data/states"
                ),
                # redirect_uri="https://w12-34.ngrok-free.app",
                redirect_uri=None,
                redirect_uri_path="/slack/authorize_app",
                install_path="/slack/install",
            )
        )

My callbacks:

        @self._fast_api.get("/slack/authorize_app")
        async def _oauth_authorize(req: Request):
            print("AUTHORIZE:::", pprint(req))
            return await self._bolt_handler.handle(req)

        @self._fast_api.get("/slack/install")
        async def _oauth_install(req: Request):
            return await self._bolt_handler.handle(req)

        # for oauth redirect
        @self._fast_api.get("/slack/oauth_redirect")
        async def _oauth_redirect(req: Request):
            return await self._bolt_handler.handle(req)

        @self._fast_api.post('/slack/events')
        async def _oauth_slack_events(req: Request):
            return await self._bolt_handler.handle(req)

Callbacks /slack/oauth_redirect and /slack/authorize_app never get called.

Reproducible in:

Sorry, I am really not sure how to reproduce this :(

The slack_bolt version

slack==0.0.2
slack_bolt==1.22.0
slack_sdk==3.34.0
slackclient==2.9.4

Python runtime version

Python 3.12

OS info

Debian 12

Steps to reproduce:

I am not sure how to reproduce this, I just think I am doing something stupid...

Expected result:

User Installation gets persisted to the ./data/installations directory.

Actual result:

Because installation does not get persisted to the ./data/installations directory, the app does not work.

@WilliamBergamin
Copy link
Contributor

Hi @X0R0X thanks for reaching out 💯

/slack/oauth_redirect is the default value for redirect_uri_path, I'm looking into your configuration redirect_uri_path="/slack/authorize_app" is set, so it should be used as the redirect uri instead of the default 🤔

Im not familiar with GCP, but the fact that the files are being written to ./data/states suggest the app it configured to write files to its volume, but it might be worth validating that files can be written to ./data/installations just to be safe

I rarely use pprint, but from the documentation and my testing, it might need to be used like this

print("AUTHORIZE:::")
pprint.pp(req)

Are you using the slack_bolt.adapter.fastapi.async_handler, we have examples/fastapi/async_oauth_app.py that shows how to use this adapter with fastapi to implement the OAuth flow it may help you understand what is happening on your end

@WilliamBergamin WilliamBergamin added the question Further information is requested label Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants