diff --git a/internal/cli/api.go b/internal/cli/api.go index 08f2da98e..2c4fa1564 100644 --- a/internal/cli/api.go +++ b/internal/cli/api.go @@ -3,6 +3,7 @@ package cli import ( "bytes" "encoding/json" + "errors" "fmt" "io" "net/http" @@ -130,6 +131,11 @@ func apiCmdRun(cli *cli, inputs *apiCmdInputs) func(cmd *cobra.Command, args []s } bearerToken := cli.config.Tenants[cli.tenant].AccessToken + + if bearerToken == "" { + return errors.New("missing access token associated with tenant. Please re-authenticate by running `auth0 login`") + } + request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", bearerToken)) request.Header.Set("Content-Type", "application/json") request.Header.Set("User-Agent", fmt.Sprintf("%s/%s", userAgent, strings.TrimPrefix(buildinfo.Version, "v")))