From 0e41dbd49780e5d25751ab962e4956f8efa4d8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=ED=9A=A8=EC=9B=90?= Date: Tue, 25 Jun 2024 13:50:52 +0900 Subject: [PATCH] fix example README.md --- README.md | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index df04534..ab09955 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Construct a new App Store Connect client, then use the various services on the c client := asc.NewClient(nil) // list all apps with the bundle ID "com.sky.MyApp" -apps, _, err := client.Apps.ListApps(&asc.ListAppsQuery{ +apps, _, err := client.Apps.ListApps(context.Background(), &asc.ListAppsQuery{ FilterBundleID: []string{"com.sky.MyApp"}, }) ``` @@ -35,6 +35,8 @@ You may find that the code snippet above will always fail due to a lack of autho ```go import ( + "context" + "log" "os" "time" @@ -47,18 +49,21 @@ func main() { // Issuer ID for the App Store Connect team issuerID := "...." // A duration value for the lifetime of a token. App Store Connect does not accept a token with a lifetime of longer than 20 minutes - expiryDuration = 20*time.Minute + expiryDuration := 20*time.Minute // The bytes of the PKCS#8 private key created on App Store Connect. Keep this key safe as you can only download it once. - privateKey = os.ReadFile("path/to/key") + privateKey, err := os.ReadFile("path/to/key") + if err != nil { + log.Fatal(err) + } - auth, err = asc.NewTokenConfig(keyID, issuerID, expiryDuration, privateKey) + auth, err := asc.NewTokenConfig(keyID, issuerID, expiryDuration, privateKey) if err != nil { - return nil, err + log.Fatal(err) } client := asc.NewClient(auth.Client()) // list all apps with the bundle ID "com.sky.MyApp" in the authenticated user's team - apps, _, err := client.Apps.ListApps(&asc.ListAppsQuery{ + apps, _, err := client.Apps.ListApps(context.Background(), &asc.ListAppsQuery{ FilterBundleID: []string{"com.sky.MyApp"}, }) } @@ -77,7 +82,7 @@ Learn more about rate limiting at