diff --git a/endpoints/endpoints.go b/endpoints/endpoints.go index 7cc37c876..1ebae5317 100644 --- a/endpoints/endpoints.go +++ b/endpoints/endpoints.go @@ -254,3 +254,16 @@ func AWSCognito(domain string) oauth2.Endpoint { TokenURL: domain + "/oauth2/token", } } + +// Shopify returns a new oauth2.Endpoint for the supplied shop domain name +// +// Example domain: my-test-shop.myshopify.com +// +// For more information see: +// https://shopify.dev/docs/apps/auth/oauth +func Shopify(domain string) oauth2.Endpoint { + return oauth2.Endpoint{ + AuthURL: "https://" + domain + "/admin/oauth/authorize", + TokenURL: "https://" + domain + "/admin/oauth/access_token", + } +} diff --git a/endpoints/endpoints_test.go b/endpoints/endpoints_test.go index 4ffa31429..6574f3ba5 100644 --- a/endpoints/endpoints_test.go +++ b/endpoints/endpoints_test.go @@ -41,3 +41,28 @@ func TestAWSCognitoEndpoint(t *testing.T) { }) } } + +func TestShopifyEndpoint(t *testing.T) { + + var endpointTests = []struct { + in string + out oauth2.Endpoint + }{ + { + in: "my-test-shop.myshopify.com", + out: oauth2.Endpoint{ + AuthURL: "https://my-test-shop.myshopify.com/admin/oauth/authorize", + TokenURL: "https://my-test-shop.myshopify.com/admin/oauth/access_token", + }, + }, + } + + for _, tt := range endpointTests { + t.Run(tt.in, func(t *testing.T) { + endpoint := Shopify(tt.in) + if endpoint != tt.out { + t.Errorf("got %q, want %q", endpoint, tt.out) + } + }) + } +}