Auth provider block
Fields
| Field | Type | Description | Required? |
|---|---|---|---|
type | String | The type of block. For an auth-provider block, type is always auth_provider. | Required |
value | String | Unique identifier for this provider within the app. Sent as the value of the Connect button and the standalone Disconnect button in interaction payloads, which identifies the provider. Their action_ids are always auth_provider_connect and auth_provider_disconnect. A Disconnect folded into your accessory overflow menu arrives on that overflow's action_id instead. Maximum 150 characters. | Required |
name | Text object | Human-readable name of the provider. Must be plain_text. Maximum 75 characters. | Required |
is_connected | Boolean | Whether this provider is currently connected or disconnected. Slack records this state for the user, so an omitted value would be indistinguishable from an explicit false and silently mark the user as disconnected. | Required |
description | Text object | Brief description of what this connection enables. Shown only while the user isn't connected. Must be plain_text. Maximum 150 characters. | Optional |
icon_url | String | URL for the provider icon image. Must be HTTPs format. Falls back to the app's avatar when absent. If the image fails to load, Slack shows a default icon. Maximum 3,000 characters. | Optional |
auth_url | String | OAuth redirect URL opened when the user clicks Connect. Must be HTTPs format on a host listed in features.user_connections.auth_hosts, or localhost while you develop. Maximum 3,000 characters. | Optional |
disconnect_url | String | URL opened when the user clicks Disconnect. Must be HTTPs format on a host listed in features.user_connections.auth_hosts, or localhost while you develop. Maximum 3,000 characters. | Optional |
connected_identity | Text object | Display name of the connected account, shown when is_connected is true. Slack keeps it for up to an hour to show your views and never saves it with a view, so send it every time you publish or update a view, and republish a Home tab to keep showing it. Must be plain_text. Maximum 75 characters. | Optional |
connected_context | Text object | Additional context about the connection, such as an org, tenant, or workspace name. Kept the same way as connected_identity. Must be plain_text. Maximum 75 characters. | Optional |
accessory | Overflow menu element | Overflow menu shown when connected (e.g., Switch accounts). Slack adds Disconnect as its first option, so up to four of your own options are shown. Picking Disconnect arrives on this overflow's action_id with a selected_option.value of auth_provider_disconnect and no provider value. Options of your own that use that value are dropped. Don't use auth_provider_connect or auth_provider_disconnect as the overflow's action_id. | Optional |
fallback | Array | Stable blocks rendered by clients that don't recognize auth_provider, spliced into the parent blocks array. | Optional |
block_id | String | A unique identifier for a block. If not specified, a block_id will be generated. | Optional |
Auth provider blocks are only supported in modals and Home tabs. You don't need to build one for Slack's connect modal: the apps.user.connection.requestAuth API method builds it from the primary_provider you pass. You can also place the block in your own modals and Home tab. If you set auth_url or disconnect_url there, your app needs features.user_connections.is_enabled set to true, and the URL's host must be listed in features.user_connections.auth_hosts.
Handling clicks
Clicks on an auth provider block reach your app as block_actions payloads. The action_ids are fixed, and the same for every provider:
| Click | action_id | Provider |
|---|---|---|
| Connect | auth_provider_connect | actions[0].value |
| Disconnect button | auth_provider_disconnect | actions[0].value |
Disconnect in your accessory overflow menu | Your overflow's action_id | Not sent as a value. selected_option.value is auth_provider_disconnect. |
If you set auth_url or disconnect_url, Slack also opens it in a new tab when the user clicks Connect or Disconnect. If you leave out auth_url, you can use the trigger_id from the auth_provider_connect payload to push your own view, such as a form for an API key, with views.push.
- Bolt JS
- Bolt Python
app.action('auth_provider_connect', async ({ ack, body }) => {
await ack();
const provider = body.actions[0].value;
});
app.action('auth_provider_disconnect', async ({ ack, body }) => {
await ack();
const provider = body.actions[0].value;
});
// With your own overflow menu, Slack's Disconnect arrives on your overflow's action_id
app.action('borant_manage', async ({ ack, body }) => {
await ack();
if (body.actions[0].selected_option.value === 'auth_provider_disconnect') {
// The user picked Disconnect
}
});
@app.action("auth_provider_connect")
def handle_connect(ack, body):
ack()
provider = body["actions"][0]["value"]
@app.action("auth_provider_disconnect")
def handle_disconnect(ack, body):
ack()
provider = body["actions"][0]["value"]
# With your own overflow menu, Slack's Disconnect arrives on your overflow's action_id
@app.action("borant_manage")
def handle_menu(ack, body):
ack()
if body["actions"][0]["selected_option"]["value"] == "auth_provider_disconnect":
... # The user picked Disconnect
The overflow pick doesn't include the provider's value, so give each provider's overflow its own action_id. Don't name it auth_provider_connect or auth_provider_disconnect, since those action_ids are Slack's.
Example
A sample auth provider block for a connected account:
- JSON
{
"type": "auth_provider",
"value": "borant",
"name": {
"type": "plain_text",
"text": "Borant"
},
"description": {
"type": "plain_text",
"text": "Get updates from Borant in Slack."
},
"is_connected": true,
"icon_url": "https://example.com/borant-logo.png",
"disconnect_url": "https://accounts.example.com/disconnect",
"connected_identity": {
"type": "plain_text",
"text": "zev@example.com"
},
"connected_context": {
"type": "plain_text",
"text": "Borant Corp workspace"
},
"accessory": {
"type": "overflow",
"action_id": "borant_manage",
"options": [
{
"text": {
"type": "plain_text",
"text": "Switch accounts"
},
"value": "switch_accounts"
}
]
}
}