Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions internal/auth0/quickstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"net/url"
"os"
"path"
"strings"

"github.com/auth0/auth0-cli/internal/buildinfo"

Check failure on line 14 in internal/auth0/quickstart.go

View workflow job for this annotation

GitHub Actions / Checks

File is not properly formatted (goimports)
"github.com/auth0/go-auth0/management"

"github.com/auth0/auth0-cli/internal/utils"
Expand Down Expand Up @@ -62,6 +64,9 @@
request.URL.RawQuery = params.Encode()
request.Header.Set("Content-Type", "application/json")

userAgent := "Auth0 CLI" // Set User-Agent header using the standard CLI format.
request.Header.Set("User-Agent", fmt.Sprintf("%v/%v", userAgent, strings.TrimPrefix(buildinfo.Version, "v")))

response, err := http.DefaultClient.Do(request)
if err != nil {
return err
Expand All @@ -71,6 +76,12 @@
return fmt.Errorf("expected status %d, got %d", http.StatusOK, response.StatusCode)
}

// Check if we're getting a zip file or HTML response

Check failure on line 79 in internal/auth0/quickstart.go

View workflow job for this annotation

GitHub Actions / Checks

Comment should end in a period (godot)
contentType := response.Header.Get("Content-Type")
if contentType != "" && !strings.Contains(contentType, "application/zip") && !strings.Contains(contentType, "application/octet-stream") {
return fmt.Errorf("expected zip file but got content-type: %s. The quickstart endpoint may have returned an error page", contentType)
}

tmpFile, err := os.CreateTemp("", "auth0-quickstart*.zip")
if err != nil {
return err
Expand Down
Loading