slack

package
v0.92.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package slack implements the Slack API provider.

Index

Constants

View Source
const (
	ID              = "slack"
	ClientIdKey     = "id"
	ClientSecretKey = "secret"
)

Variables

This section is empty.

Functions

func Register

func Register()

Register registers the Slack OAuth provider in the global provider registry.

Types

type IdentityResponse

type IdentityResponse struct {
	OK    bool         `json:"ok"`
	Error string       `json:"error,omitempty"`
	User  IdentityUser `json:"user"`
	Team  IdentityTeam `json:"team"`
}

IdentityResponse represents the Slack users.identity API response.

type IdentityTeam

type IdentityTeam struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

IdentityTeam represents the team in the identity response.

type IdentityUser

type IdentityUser struct {
	Name    string `json:"name"`
	ID      string `json:"id"`
	Image48 string `json:"image_48"`
}

IdentityUser represents the user in the identity response.

type OAuthAuthedUser

type OAuthAuthedUser struct {
	ID           string `json:"id"`
	Scope        string `json:"scope"`
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token,omitempty"`
}

OAuthAuthedUser represents the authed_user in the OAuth response.

type OAuthTeam

type OAuthTeam struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

OAuthTeam represents the team in the OAuth response.

type OAuthV2AccessResponse

type OAuthV2AccessResponse struct {
	OK         bool            `json:"ok"`
	Error      string          `json:"error,omitempty"`
	AuthedUser OAuthAuthedUser `json:"authed_user"`
	Team       OAuthTeam       `json:"team"`
}

OAuthV2AccessResponse represents the Slack oauth.v2.access API response.

type Slack

type Slack struct {
	// contains filtered or unexported fields
}

Slack implements the OAuthProvider interface for Slack's OAuth v2 flow using the Sign in with Slack (identity.*) scopes.

func GetClient

func GetClient() *Slack

GetClient reads OAuth provider config and returns a new Slack client suitable for OAuth authorization flows.

func NewSlack

func NewSlack(clientId, clientSecret, redirectURI, accessToken string) *Slack

NewSlack creates a new Slack OAuth provider instance.

func (*Slack) GetAccessToken

func (v *Slack) GetAccessToken(ctx fiber.Ctx) (*providers.OAuthToken, error)

GetAccessToken implements the OAuthProvider interface. It exchanges the authorization code from the callback for a user access token and returns the token data as a typed OAuthToken.

func (*Slack) GetAuthorizeURL

func (v *Slack) GetAuthorizeURL(state string) string

GetAuthorizeURL returns the Slack OAuth v2 authorization URL with identity.basic and identity.avatar user scopes. The state parameter is included for CSRF protection.

func (*Slack) GetIdentity

func (v *Slack) GetIdentity() (*IdentityResponse, error)

GetIdentity uses the access token to fetch the authenticated user's identity from the Slack users.identity API.

func (*Slack) RefreshAccessToken

func (v *Slack) RefreshAccessToken(ctx context.Context, refreshToken string) (*providers.OAuthToken, error)

RefreshAccessToken implements OAuthRefresher for Slack. Slack supports token rotation for certain scopes via the refresh_token grant.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL