MCPcopy
hub / github.com/ory/hydra / IntrospectToken

Function IntrospectToken

internal/testhelpers/oauth2.go:113–127  ·  view source on GitHub ↗
(t testing.TB, token string, adminTS *httptest.Server)

Source from the content-addressed store, hash-verified

111}
112
113func IntrospectToken(t testing.TB, token string, adminTS *httptest.Server) gjson.Result {
114 require.NotEmpty(t, token)
115
116 req := httpx.MustNewRequest("POST", adminTS.URL+"/admin/oauth2/introspect",
117 strings.NewReader((url.Values{"token": {token}}).Encode()),
118 "application/x-www-form-urlencoded")
119
120 res, err := adminTS.Client().Do(req)
121 require.NoError(t, err)
122 defer res.Body.Close() //nolint:errcheck
123 body, err := io.ReadAll(res.Body)
124 require.NoError(t, err)
125 require.Equalf(t, http.StatusOK, res.StatusCode, "Response body: %s", body)
126 return gjson.ParseBytes(body)
127}
128
129func RevokeToken(t testing.TB, conf *oauth2.Config, token string, publicTS *httptest.Server) gjson.Result {
130 require.NotEmpty(t, token)

Calls 3

ClientMethod · 0.65
CloseMethod · 0.65
EncodeMethod · 0.45