api.integrations.shopify.auth ============================= .. py:module:: api.integrations.shopify.auth .. autoapi-nested-parse:: Shopify Admin API access tokens, exchanged from the app's client credentials. A Dev Dashboard app has no permanent token: SHOPIFY_CLIENT_ID and SHOPIFY_CLIENT_SECRET are exchanged for a token that Shopify expires after about 24 hours. The token is kept in Redis, so the API and every worker share one exchange, plus in memory; it is renewed before it expires. After a 401 (token revoked early), callers ask again with the rejected token, which forces a new exchange unless another process already has a newer one. Without Redis, the in-memory copy alone is used. Attributes ---------- .. autoapisummary:: api.integrations.shopify.auth.logger api.integrations.shopify.auth.REQUEST_TIMEOUT_SECONDS api.integrations.shopify.auth.REFRESH_MARGIN_SECONDS api.integrations.shopify.auth.EXCHANGE_LOCK_TTL_SECONDS api.integrations.shopify.auth.EXCHANGE_WAIT_SECONDS api.integrations.shopify.auth.EXCHANGE_WAIT_POLL_SECONDS api.integrations.shopify.auth.TokenProvider Exceptions ---------- .. autoapisummary:: api.integrations.shopify.auth.ShopifyAuthError Classes ------- .. autoapisummary:: api.integrations.shopify.auth.ShopifyTokenProvider Functions --------- .. autoapisummary:: api.integrations.shopify.auth.exchange_client_credentials api.integrations.shopify.auth.get_shopify_access_token Module Contents --------------- .. py:data:: logger .. py:data:: REQUEST_TIMEOUT_SECONDS :value: 30 .. py:data:: REFRESH_MARGIN_SECONDS :value: 600 .. py:data:: EXCHANGE_LOCK_TTL_SECONDS :value: 30 .. py:data:: EXCHANGE_WAIT_SECONDS :value: 10.0 .. py:data:: EXCHANGE_WAIT_POLL_SECONDS :value: 0.25 .. py:data:: TokenProvider .. py:exception:: ShopifyAuthError Bases: :py:obj:`RuntimeError` No Admin API access token could be obtained. .. py:function:: exchange_client_credentials(domain: str, client_id: str, client_secret: str) -> tuple[str, int] (access_token, expires_in seconds) straight from Shopify. .. py:class:: ShopifyTokenProvider(domain: str, client_id: str, client_secret: str, redis_factory: collections.abc.Callable[[], redis.Redis[str]] | None = None) Returns a valid token for one store (see the module docstring). .. py:attribute:: domain .. py:attribute:: client_id .. py:attribute:: client_secret .. py:function:: get_shopify_access_token(rejected: str | None = None) -> str A token for the configured store (SHOPIFY_SHOP_DOMAIN).