@@ -9,9 +9,12 @@ import (
99 "net/url"
1010 "os"
1111 "path"
12+ "strings"
1213
1314 "github.com/auth0/go-auth0/management"
1415
16+ "github.com/auth0/auth0-cli/internal/buildinfo"
17+
1518 "github.com/auth0/auth0-cli/internal/utils"
1619)
1720
@@ -62,6 +65,9 @@ func (q Quickstart) Download(ctx context.Context, downloadPath string, client *m
6265 request .URL .RawQuery = params .Encode ()
6366 request .Header .Set ("Content-Type" , "application/json" )
6467
68+ userAgent := "Auth0 CLI" // Set User-Agent header using the standard CLI format.
69+ request .Header .Set ("User-Agent" , fmt .Sprintf ("%v/%v" , userAgent , strings .TrimPrefix (buildinfo .Version , "v" )))
70+
6571 response , err := http .DefaultClient .Do (request )
6672 if err != nil {
6773 return err
@@ -71,6 +77,12 @@ func (q Quickstart) Download(ctx context.Context, downloadPath string, client *m
7177 return fmt .Errorf ("expected status %d, got %d" , http .StatusOK , response .StatusCode )
7278 }
7379
80+ // Check if we're getting a zip file or HTML response.
81+ contentType := response .Header .Get ("Content-Type" )
82+ if contentType != "" && ! strings .Contains (contentType , "application/zip" ) && ! strings .Contains (contentType , "application/octet-stream" ) {
83+ return fmt .Errorf ("expected zip file but got content-type: %s. The quickstart endpoint may have returned an error page" , contentType )
84+ }
85+
7486 tmpFile , err := os .CreateTemp ("" , "auth0-quickstart*.zip" )
7587 if err != nil {
7688 return err
0 commit comments