Skip to main content

oauth2 type

This reference documents the Slack types at the platform level. Their availability and structure may differ in each SDK

Type: slack#/types/credential/oauth2

PropertyTypeDescription
defaultThe type that is being described.An optional parameter default value.
descriptionstringAn optional parameter description.
examplesAn array of the type being described.An optional list of examples.
hintstringAn optional parameter hint.
titlestringAn optional parameter title.
typestringString that defines the parameter type.

Declare an oauth2 type:

// ...
"github_access_token_id": {
"type": "slack#/types/credential/oauth2",
"oauth2_provider_key": "github"
}
// ...
OAuth2 example

In this example, we use the oauth2 type for an input parameter in a custom function. To read more about a full implementation of oauth2, check out External authentication.

export const CreateIssueDefinition = DefineFunction({
callback_id: "create_issue",
title: "Create GitHub issue",
description: "Create a new GitHub issue in a repository",
source_file: "functions/create_issue.ts",
input_parameters: {
properties: {
githubAccessTokenId: {
type: Schema.slack.types.oauth2,
oauth2_provider_key: "github",
},
url: {
type: Schema.types.string,
description: "Repository URL",
},

// ...

},
output_parameters: {
properties: {
GitHubIssueNumber: {
type: Schema.types.number,
description: "Issue number",
},
GitHubIssueLink: {
type: Schema.types.string,
description: "Issue link",
},
},
required: ["GitHubIssueNumber", "GitHubIssueLink"],
},
});