Slack API client library for kiarina namespace
Project description
kiarina-lib-slack
English | 日本語
[!NOTE] What is this? A package for managing Slack app credentials and OAuth information with pydantic-settings-manager.
Dependencies
| Package | Version | License |
|---|---|---|
| Pydantic Settings | >=2.10.1 |
MIT |
| pydantic-settings-manager | >=3.2.0 |
MIT |
A Slack SDK is not included as a dependency. Add one to the application that creates the Slack client.
Installation
pip install kiarina-lib-slack
Features
- Configuring a Slack App Store Slack app credentials, OAuth scopes, and workspace information.
- Managing Multiple Apps Switch between named settings for multiple Slack apps.
- Loading Environment Variables
Load environment variables with the
KIARINA_LIB_SLACK_prefix. - Using Socket Mode Store an app-level token for Socket Mode.
- Protecting Secrets
Store client secrets, signing secrets, and tokens as
SecretStr.
Configuring a Slack App
app_id, client_id, client_secret, and signing_secret are required.
from kiarina.lib.slack import SlackSettings
settings = SlackSettings(
app_id="A0123456789",
client_id="123456789.123456789",
client_secret="client-secret",
signing_secret="signing-secret",
bot_token="xoxb-...",
scopes=["chat:write"],
)
Managing Multiple Apps
settings_manager uses multiple-settings mode. Place named settings under configs.
kiarina.lib.slack:
default: production
configs:
development:
app_id: A_DEVELOPMENT
client_id: development-client
client_secret: development-secret
signing_secret: development-signing-secret
production:
app_id: A_PRODUCTION
client_id: production-client
client_secret: production-secret
signing_secret: production-signing-secret
import yaml
from pydantic_settings_manager import load_user_configs
from kiarina.lib.slack import settings_manager
with open("config.yaml", encoding="utf-8") as file:
load_user_configs(yaml.safe_load(file) or {})
settings = settings_manager.get_settings("production")
Loading Environment Variables
Set the scopes list as a JSON array.
export KIARINA_LIB_SLACK_APP_ID="A0123456789"
export KIARINA_LIB_SLACK_CLIENT_ID="123456789.123456789"
export KIARINA_LIB_SLACK_CLIENT_SECRET="client-secret"
export KIARINA_LIB_SLACK_SIGNING_SECRET="signing-secret"
export KIARINA_LIB_SLACK_SCOPES='["chat:write"]'
from kiarina.lib.slack import SlackSettings
settings = SlackSettings()
Using Socket Mode
For Socket Mode, set an xapp- token as app_token.
settings = SlackSettings(
app_id="A0123456789",
client_id="123456789.123456789",
client_secret="client-secret",
signing_secret="signing-secret",
app_token="xapp-...",
)
Protecting Secrets
Extract secret values only where they are passed to an SDK.
bot_token = (
settings.bot_token.get_secret_value()
if settings.bot_token is not None
else None
)
API Reference
kiarina.lib.slack
from kiarina.lib.slack import (
SlackSettings,
settings_manager,
)
SlackSettings
class SlackSettings(BaseSettings):
def __init__(
self,
*,
app_id: str,
client_id: str,
client_secret: SecretStr,
signing_secret: SecretStr,
app_token: SecretStr | None = None,
scopes: list[str] = [],
team_id: str | None = None,
enterprise_id: str | None = None,
bot_token: SecretStr | None = None,
) -> None: ...
Slack app settings.
Fields
app_id(str): Slack app ID.client_id(str): Slack OAuth client ID.client_secret(SecretStr): Slack OAuth client secret.signing_secret(SecretStr): Slack request signing secret.app_token(SecretStr | None): App-level token for Socket Mode.scopes(list[str]): OAuth scopes requested by the Slack app.team_id(str | None): Slack workspace ID.enterprise_id(str | None): Slack Enterprise Grid organization ID.bot_token(SecretStr | None): Slack bot user OAuth token.
settings_manager
settings_manager: SettingsManager[SlackSettings]
Global instance that manages named Slack app settings.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kiarina_lib_slack-2.3.1.tar.gz.
File metadata
- Download URL: kiarina_lib_slack-2.3.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44fae230bb19c73419d262d0d1626292e7ff9a5e731155fb89b7df1e29d05b0c
|
|
| MD5 |
a89199996cf1289461e3818b19c9927b
|
|
| BLAKE2b-256 |
6d7baebf8b0092f3339d8bac298ae670a6a9c59560ee6c5368e69ccf394ceb92
|
Provenance
The following attestation bundles were made for kiarina_lib_slack-2.3.1.tar.gz:
Publisher:
release-pypi.yml on kiarina/kiarina-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kiarina_lib_slack-2.3.1.tar.gz -
Subject digest:
44fae230bb19c73419d262d0d1626292e7ff9a5e731155fb89b7df1e29d05b0c - Sigstore transparency entry: 2044312952
- Sigstore integration time:
-
Permalink:
kiarina/kiarina-python@443dbb48340706ef8cf35551de167d64bc11ee82 -
Branch / Tag:
refs/tags/v2.3.1 - Owner: https://github.com/kiarina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@443dbb48340706ef8cf35551de167d64bc11ee82 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kiarina_lib_slack-2.3.1-py3-none-any.whl.
File metadata
- Download URL: kiarina_lib_slack-2.3.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f7dd0a70076faedbcc1497fcbd4ec47674d11335814b68653fcd7b8fd3580bd
|
|
| MD5 |
73b1cfa513d4cc005968e66c25f3b976
|
|
| BLAKE2b-256 |
21820b73002f42c55298d0365fa44406853be536bd943017a67cae88f119f234
|
Provenance
The following attestation bundles were made for kiarina_lib_slack-2.3.1-py3-none-any.whl:
Publisher:
release-pypi.yml on kiarina/kiarina-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kiarina_lib_slack-2.3.1-py3-none-any.whl -
Subject digest:
7f7dd0a70076faedbcc1497fcbd4ec47674d11335814b68653fcd7b8fd3580bd - Sigstore transparency entry: 2044312979
- Sigstore integration time:
-
Permalink:
kiarina/kiarina-python@443dbb48340706ef8cf35551de167d64bc11ee82 -
Branch / Tag:
refs/tags/v2.3.1 - Owner: https://github.com/kiarina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@443dbb48340706ef8cf35551de167d64bc11ee82 -
Trigger Event:
push
-
Statement type: