busy_beaver/apps/slack_integration/oauth/workflow.py
def process_slack_installation_callback(callback_url):
    """Verify callback and save tokens in the database"""
    oauth_details = slack_install_oauth.process_callback(callback_url)
    oauth_dict = oauth_details._asdict()

    # TODO update or create seems like a useful helper function
    existing_installation = SlackInstallation.query.filter_by(
        workspace_id=oauth_details.workspace_id
    ).first()
    if existing_installation:
        existing_installation.patch(oauth_dict)
        installation = existing_installation
    else:
        installation = SlackInstallation(**oauth_dict)

    db.session.add(installation)
    db.session.commit()
    return installation
Verify callback and save tokens in the database
Verify callback and save tokens in the database
Verify callback and save tokens in the database
def process_slack_installation_callback(callback_url):
    oauth_details = slack_install_oauth.process_callback(callback_url)
    oauth_dict = oauth_details._asdict()
    existing_installation = SlackInstallation.query.filter_by(
        workspace_id=oauth_details.workspace_id
    ).first()
    if existing_installation:
        existing_installation.patch(oauth_dict)
        installation = existing_installation
    else:
        installation = SlackInstallation(**oauth_dict)
    db.session.add(installation)
    db.session.commit()
    return installation
def process_slack_installation_callback ( callback_url ) : oauth_details = slack_install_oauth . process_callback ( callback_url ) oauth_dict = oauth_details . _asdict ( ) existing_installation = SlackInstallation . query . filter_by ( workspace_id = oauth_details . workspace_id ) . first ( ) if existing_installation : existing_installation . patch ( oauth_dict ) installation = existing_installation else : installation = SlackInstallation ( ** oauth_dict ) db . session . add ( installation ) db . session . commit ( ) return installation
Verify callback and save tokens in the database
Verify callback and save tokens in the database
"""Verify callback and save tokens in the database""" # TODO update or create seems like a useful helper function
callback_url