Skip to content

Commit

Permalink
fix: add content-type header to hook request (#2775)
Browse files Browse the repository at this point in the history
  • Loading branch information
svrakitin committed Oct 1, 2021
1 parent 8901b09 commit 8d0e5e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions oauth2/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func RefreshTokenHook(config *config.Provider) AccessRequestHook {
WithDebug("refresh token hook: new http request"),
)
}
req.Header.Set("Content-Type", "application/json; charset=UTF-8")

resp, err := client.Do(req)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions oauth2/oauth2_auth_code_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,8 @@ func TestAuthCodeWithMockStrategy(t *testing.T) {

t.Run("should call refresh token hook if configured", func(t *testing.T) {
hs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, r.Header.Get("Content-Type"), "application/json; charset=UTF-8")

var hookReq hydraoauth2.RefreshTokenHookRequest
require.NoError(t, json.NewDecoder(r.Body).Decode(&hookReq))
require.Equal(t, hookReq.Subject, "foo")
Expand Down

0 comments on commit 8d0e5e6

Please sign in to comment.