Skip to content

Commit

Permalink
urlencode auth post data
Browse files Browse the repository at this point in the history
  • Loading branch information
tedpearson committed Mar 6, 2024
1 parent b2144b6 commit 440f0ef
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/app/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ type OAuth struct {
// Auth authenticates with the api and returns a json web token for use with the api.
func Auth(config UtilityConfig) (string, error) {
client := &http.Client{}
postData := fmt.Sprintf("userId=%s&password=%s", config.Username, config.Password)
formData := url.Values{}
formData.Set("userId", config.Username)
formData.Set("password", config.Password)
authUrl := fmt.Sprintf("%s/services/oauth/auth/v2", config.ApiUrl)
parsed, err := url.Parse(config.ApiUrl)
authority := parsed.Hostname()
req, err := http.NewRequest("POST", authUrl, strings.NewReader(postData))
req, err := http.NewRequest("POST", authUrl, strings.NewReader(formData.Encode()))
if err != nil {
return "", err
}
Expand Down

0 comments on commit 440f0ef

Please sign in to comment.