Skip to content

Not_authed after installing bot to workspace #464

@moffire

Description

@moffire

The slack_bolt version

slack-bolt==1.6.0
slack-sdk==3.5.1

Python runtime version

Python 3.9.5

OS info

Kubuntu 21.04

Steps to reproduce:

I installed my bot to the workspace using https://{my_domain}/slack/install. After redirecting the new folder in the bot directory was created (fig. #1). But when I'm trying to interact with the bot, I receive errors. I have no idea how to fix it.

slack_sdk.oauth.installation_store.file:Failed to find an installation data for enterprise: none, team: T02EE4YKJSD: [Errno 2] No such file or directory: './data/none-T02EE4YKJSD/installer-U02DYHJN5B7-latest'
The server responded with: {'ok': False, 'error': 'not_authed'})

Fig #1
image

ENV Vairables

SLACK_SIGNING_SECRET=XXXX
SLACK_CLIENT_SECRET=YYYY

Code

SLACK_CLIENT_ID = _here's_client_id_
oauth_settings = OAuthSettings(
    client_id=SLACK_CLIENT_ID,
    client_secret=os.environ['SLACK_CLIENT_SECRET'],
    scopes=['channels:history', 'channels:read', 'chat:write', 'commands,groups:read', 'im:read', 'im:write',
            'users.profile:read', 'users:read', 'users:read.email'],
    user_scopes=['users:read'],
    state_store=FileOAuthStateStore(expiration_seconds=600, base_dir="./data")
)

app = App(signing_secret=os.environ['SLACK_SIGNING_SECRET'],
          installation_store=FileInstallationStore(base_dir="./data"),
          oauth_settings=oauth_settings)

handler = SlackRequestHandler(app)

# Flask adapter
flask_adapter = Flask(__name__)

@app.event('member_joined_channel')
def member_joined_channel(body):
    channel_id = body.get('event')['channel']
    channel_members = app.client.conversations_members(channel=channel_id).data.get('members')
    print(channel_members)

@flask_adapter.route("/slack/install", methods=["GET"])
def install():
    return handler.handle(request)

@flask_adapter.route("/slack/oauth_redirect", methods=["GET"])
def oauth_redirect():
    return handler.handle(request)

Expected result:

Receive a correct response from the server

Actual result:

Server responded with: {'ok': False, 'error': 'not_authed'})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions