Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

using-b2c-tooling-sdk

БесплатноБез исполняемых скриптовНе проверен

Consuming the salesforce-b2c-tooling-sdk Python SDK from scripts or Jupyter notebooks — installation, choosing an authentication mechanism, and the available…

SalesforceCommerceCloudот SalesforceCommerceCloud★ 58 звёзд на GitHub

Об этом скилле

Using the B2C Tooling SDK (Python)

salesforce-b2c-tooling-sdk is the Python SDK for Salesforce B2C Commerce tooling. Import name is b2c_tooling_sdk; distribution name is salesforce-b2c-tooling-sdk. It is async-first with a complete synchronous facade. Python 3.10+.

This skill covers consuming the SDK. For developing the SDK itself, see python/b2c-tooling-sdk/CLAUDE.md. For the full symbol catalog, read references/api-catalog.md.

1. Install

Not on PyPI yet — install from git during development:

pip install "git+https://github.com/SalesforceCommerceCloud/b2c-developer-tooling.git@main#subdirectory=python/b2c-tooling-sdk"
# or pin a release tag: ...@<tag>#subdirectory=python/b2c-tooling-sdk

For notebooks also install a kernel: pip install ipykernel. Once published this becomes pip install salesforce-b2c-tooling-sdk.

2. Async vs. sync — pick the import root

The two surfaces are identical except one word: sync drops await.

Context Import from Style
Scripts / notebooks / REPL b2c_tooling_sdk.sync blocking, no await
Inside an existing event loop (web server, async app) b2c_tooling_sdk await

Notebooks: use the sync facade — it is the frictionless path (no asyncio.run, no await). All sync calls run on one shared background loop, so token caching still works.

# Notebook / script (sync)
from b2c_tooling_sdk.sync import resolve_config
from b2c_tooling_sdk.sync import list_code_versions

config = resolve_config()                       # blocks
instance = config.create_b2c_instance()
for v in list_code_versions(instance):
    print(v.id, "active" if v.active else "")
# Async
import asyncio
from b2c_tooling_sdk import resolve_config
from b2c_tooling_sdk.operations.code import list_code_versions

async def main() -> None:
    config = await resolve_config()
    instance = config.create_b2c_instance()
    for v in await list_code_versions(instance):
        print(v.id)

asyncio.run(main())

Never call the sync facade from inside a running event loop (including async notebook cells / await-ing cells) — it waits on a background loop and can deadlock. In async code, import from b2c_tooling_sdk and await.

Streaming APIs (tail_logs, cartridge watching) are async-only — not in the sync facade. Use the async API for those.

The examples below use the async form. For sync, import the same names from b2c_tooling_sdk.sync and drop await.

3. Authenticate — choose by use case

Credentials usually come from a dw.json via resolve_config() (see §4). If you already have a dw.json, prefer resolve_config + create_b2c_instance() — it selects the auth mechanism for you. Reach for an explicit strategy only when you have no config file or need a specific flow.

Use case Mechanism How
Server-to-server automation (CI, scripts) OAuth client-credentials OAuthStrategy(OAuthConfig(client_id, client_secret, scopes))
Server-to-server with a cert instead of a secret JWT Bearer JwtOAuthStrategy(JwtOAuthConfig(client_id, cert_path, key_path, ...))
Interactive user login (opens a browser) PKCE (+ implicit fallback) create_user_auth_strategy(PkceOAuthConfig(client_id=..., account_manager_host=...))
Reuse a session created by b2c auth login shared session store resolve_config() picks it up automatically; or find_auth_session(client_id)
WebDAV / OCAPI Basic auth Basic BasicAuthStrategy(username, password)
Static API key header API key ApiKeyStrategy("my-key")
Storefront shopper tokens (guest/registered) SLAS b2c_tooling_sdk.slas.get_guest_token(...) — see §6
from b2c_tooling_sdk.auth import OAuthStrategy, OAuthConfig

auth = OAuthStrategy(OAuthConfig(
    client_id="...", client_secret="...", scopes=["sfcc.products"],
))

CLI interoperability: the SDK shares the same on-disk auth-sessions.json and config files as the @salesforce/b2c-cli. Recommended interactive workflow: run b2c auth login --client-id <clientId> once, then run non-interactive Python — it reuses the session with no browser prompt. find_auth_session, is_auth_session_token_valid, and list_auth_sessions inspect the store.

Don't know which methods a credential bundle supports? Use resolve_auth_strategy(AuthCredentials(...), allowed_methods=[...]) to pick the best available, or check_available_auth_methods(...) to probe without side effects.

4. Resolve config from dw.json

resolve_config() merges the same sources the CLI reads (dw.json walking up from cwd, ~/.mobify, package.json, settings.json) into a resolved config whose .create_b2c_instance() builds an authenticated B2CInstance.

from b2c_tooling_sdk import resolve_config, NormalizedConfig

config = await resolve_config()
Полный SKILL.md на GitHub

Установить using-b2c-tooling-sdk в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/api-catalog.md

FAQ

Что делает скилл using-b2c-tooling-sdk?

Consuming the salesforce-b2c-tooling-sdk Python SDK from scripts or Jupyter notebooks — installation, choosing an authentication mechanism, and the available OCAPI/SCAPI/WebDAV clients and operations. Use when writing Python (or notebook) code that authenticates to a B2C Commerce instance, resolves config from dw.json, deploys code, runs jobs, reads sites/catalogs/logs/metrics, provisions sandboxes, or mints SLAS shopper tokens.

Как установить скилл using-b2c-tooling-sdk?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл using-b2c-tooling-sdk запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить using-b2c-tooling-sdk с