Add client authentication

This commit is contained in:
Pal Kerecsenyi 2023-10-21 12:46:25 +01:00
parent 362abaf813
commit 2eaa30305b
Signed by: palk
GPG Key ID: 6891661E25394C2C

View File

@ -39,10 +39,12 @@ func mapToQuery(variables map[string]string) (output string) {
} }
func (c *PalAuthIAMClient) buildURL(path string, query map[string]string) string { func (c *PalAuthIAMClient) buildURL(path string, query map[string]string) string {
return fmt.Sprintf("%s%s?%s", c.baseURL, path, mapToQuery(query)) return fmt.Sprintf("%s/%s%s?%s", c.baseURL, c.clientId, path, mapToQuery(query))
} }
func (c *PalAuthIAMClient) runRequest(req *http.Request, mapTo interface{}) error { func (c *PalAuthIAMClient) runRequest(req *http.Request, mapTo interface{}) error {
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.clientSecret))
res, err := http.DefaultClient.Do(req) res, err := http.DefaultClient.Do(req)
if err != nil { if err != nil {
return fmt.Errorf("making request: %s", err) return fmt.Errorf("making request: %s", err)