Slack API client providing comprehensive Python interface for messaging, file sharing, user management, and team communication features.
—
Authentication and authorization functionality for Slack API access, including token validation, revocation, and OAuth flow implementation.
Test your authentication token and retrieve information about the authenticated user or bot.
def test(self):
"""
Test authentication token and return information about the authenticated user/bot.
Returns:
Response: Contains user/bot information including user_id, team_id, and token scope
"""Usage:
slack = Slacker(token)
response = slack.auth.test()
if response.successful:
user_id = response.body['user_id']
team_id = response.body['team_id']Revoke the current authentication token to invalidate access.
def revoke(self, test=True):
"""
Revoke the current authentication token.
Args:
test (bool): Whether to test token validity before revoking (default: True)
Returns:
Response: Confirmation of token revocation
"""Exchange an OAuth code for an access token during the OAuth flow.
def access(self, client_id, client_secret, code, redirect_uri=None):
"""
Exchange OAuth code for access token.
Args:
client_id (str): Slack app client ID
client_secret (str): Slack app client secret
code (str): OAuth authorization code
redirect_uri (str, optional): Redirect URI used in authorization
Returns:
Response: Contains access_token and other OAuth response data
"""Exchange an OAuth code for a workspace token with additional options.
def token(self, client_id, client_secret, code, redirect_uri=None, single_channel=None):
"""
Exchange OAuth code for workspace token with extended options.
Args:
client_id (str): Slack app client ID
client_secret (str): Slack app client secret
code (str): OAuth authorization code
redirect_uri (str, optional): Redirect URI used in authorization
single_channel (str, optional): Restrict token to single channel
Returns:
Response: Contains access_token and workspace information
"""class Auth(BaseAPI):
"""Authentication and authorization endpoint handler."""
def test(self): ...
def revoke(self, test=True): ...
class OAuth(BaseAPI):
"""OAuth flow endpoint handler."""
def access(self, client_id, client_secret, code, redirect_uri=None): ...
def token(self, client_id, client_secret, code, redirect_uri=None, single_channel=None): ...Install with Tessl CLI
npx tessl i tessl/pypi-slacker