diff --git a/internal/cli/apis.go b/internal/cli/apis.go index 3dbd901a0..107b7f174 100644 --- a/internal/cli/apis.go +++ b/internal/cli/apis.go @@ -1,10 +1,14 @@ package cli import ( + "fmt" "github.com/auth0/auth0-cli/internal/ansi" "github.com/auth0/auth0-cli/internal/prompt" "github.com/spf13/cobra" "gopkg.in/auth0.v5/management" + "io/ioutil" + "net/http" + "strings" ) func apisCmd(cli *cli) *cobra.Command { @@ -181,6 +185,35 @@ auth0 apis get-token --audience url `, RunE: func(cmd *cobra.Command, args []string) error { + cli.renderer.Infof("Requesting token...") + + domain := "half-ogre-preview.auth0.com" + + url := "https://" + domain + "/oauth/token" + client_id := "EMWsMvfZWFTBmZySFy8wcixosiiOGbK0" + client_secret := "4c3gyaIKKTj17T8lUhtJGUXSspMLuOYdLXQYLiRkmcr7Us06OmlksFNXit8IATah" + + // This is audience + api_identifier := "https://cli.test.auth0.fake" + + payload := strings.NewReader("grant_type=client_credentials&client_id=" + client_id + "&client_secret=" + client_secret + "&audience=" + api_identifier) + + req, _ := http.NewRequest("POST", url, payload) + + req.Header.Add("content-type", "application/x-www-form-urlencoded") + + res, err := http.DefaultClient.Do(req) + + if err != nil { + fmt.Println(err) + return nil + } + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) return nil }, }