Test-ShopifyAccess #
ÜBERSICHT #
Prüft ob ein Shopify API-Token die benötigten Berechtigungen (Scopes) hat.
SYNTAX #
Test-ShopifyAccess [-Shop] <string> [-Token] <string> [-ApiVersion] <string> [-RequiredScopes]
<string[]> [[-TimeoutSec] <int>] [<CommonParameters>]
BESCHREIBUNG #
Ruft den Shopify-Endpunkt /admin/oauth/access_scopes.json ab und vergleicht die gewährten Scopes mit den angeforderten. Gibt ein Ergebnisobjekt zurück, das anzeigt ob alle benötigten Scopes vorhanden sind und welche ggf. fehlen.
Typischer Einsatz als Preflight-Check vor dem eigentlichen Workflow, um kryptische 403-Fehler auf einzelnen Endpoints frühzeitig zu erkennen.
PARAMETER #
-Shop #
Type: string
Shopify-Shop-Domain, z.B. ‘mein-shop.myshopify.com’.
-Token #
Type: string
Admin API Access Token (shpat_…) der Custom App.
-ApiVersion #
Type: string
API-Version, z.B. ‘2025-01’.
-RequiredScopes #
Type: string[]
Array der benötigten Scopes, z.B. @(‘read_products’, ‘write_orders’).
-TimeoutSec #
Type: int
Default: 60
HTTP Timeout in Sekunden.
AUSGABEN #
pscustomobject -- Objekt mit Valid, GrantedScopes, RequiredScopes, MissingScopes.
BEISPIELE #
# Preflight-Check für Bestellimport
$check = Test-ShopifyAccess -Shop 'mein-shop.myshopify.com' `
-Token 'shpat_abc123' -ApiVersion '2025-01' `
-RequiredScopes @('read_orders', 'write_orders')
if (-not $check.Valid) {
throw "Fehlende Scopes: $($check.MissingScopes -join ', ')"
}
# Alle Scopes abfragen ohne Pflichtprüfung
$check = Test-ShopifyAccess -Shop $shop -Token $token `
-ApiVersion '2025-01' -RequiredScopes @()
$check.GrantedScopes # Zeigt alle gewährten Scopes