Skip to content

Commit

Permalink
Merge pull request #2 from harunnryd/fix/client/charset
Browse files Browse the repository at this point in the history
fix(go): add accept-charset utf-8
  • Loading branch information
harunnryd committed Oct 10, 2022
2 parents ffd62b2 + 5bf76de commit cbea733
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,29 @@ func (client *gocloak) getRequestWithBearerAuthNoCache(ctx context.Context, toke
return client.getRequest(ctx).
SetAuthToken(token).
SetHeader("Content-Type", "application/json").
SetHeader("Cache-Control", "no-cache")
SetHeader("Cache-Control", "no-cache").
SetHeader("Accept-Charset", "utf-8")
}

func (client *gocloak) getRequestWithBearerAuth(ctx context.Context, token string) *resty.Request {
return client.getRequest(ctx).
SetAuthToken(token).
SetHeader("Content-Type", "application/json")
SetHeader("Content-Type", "application/json").
SetHeader("Accept-Charset", "utf-8")
}

func (client *gocloak) getRequestWithBearerAuthXMLHeader(ctx context.Context, token string) *resty.Request {
return client.getRequest(ctx).
SetAuthToken(token).
SetHeader("Content-Type", "application/xml;charset=UTF-8")
SetHeader("Content-Type", "application/xml;charset=UTF-8").
SetHeader("Accept-Charset", "utf-8")
}

func (client *gocloak) getRequestWithBasicAuth(ctx context.Context, clientID, clientSecret string) *resty.Request {
req := client.getRequest(ctx).
SetHeader("Content-Type", "application/x-www-form-urlencoded")
SetHeader("Content-Type", "application/x-www-form-urlencoded").
SetHeader("Accept-Charset", "utf-8")

// Public client doesn't require Basic Auth
if len(clientID) > 0 && len(clientSecret) > 0 {
httpBasicAuth := base64.StdEncoding.EncodeToString([]byte(clientID + ":" + clientSecret))
Expand Down Expand Up @@ -3581,6 +3586,7 @@ func (client *gocloak) UpdateCredentialUserLabel(ctx context.Context, token, rea

resp, err := client.getRequestWithBearerAuth(ctx, token).
SetHeader("Content-Type", "text/plain").
SetHeader("Accept-Charset", "utf-8").
SetBody(userLabel).
Put(client.getAdminRealmURL(realm, "users", userID, "credentials", credentialID, "userLabel"))

Expand Down

0 comments on commit cbea733

Please sign in to comment.