<@U04UQ68083H> can we store custom information whe...
# ory-copilot
g
@chilly-king-10285 can we store custom information when creating oauth2 clients in hydra ?
c
A message from kapa.ai
Yes, you can store custom information when creating OAuth2 clients in Ory Hydra. The client model includes a field called
metadata
, which is designed to hold arbitrary JSON data. This allows you to attach custom information to each OAuth2 client at creation time. The
metadata
field is of type
object
and is intended for storing additional data that may be relevant to your application or integration needs. Here is an excerpt from the API schema:
Copy code
json "metadata": {   "title": "JSONRawMessage represents a json.RawMessage that works well with JSON, SQL, and Swagger.",   "type": "object" }
You can include this field in your client creation request, for example:
Copy code
json {   "client_name": "My App",   "redirect_uris": ["<https://my-app.com/callback>"],   "grant_types": ["authorization_code"],   "response_types": ["code"],   "scope": "openid",   "metadata": {     "custom_key": "custom_value",     "another_key": 123   } }
This custom data will be stored with the client and can be retrieved when you fetch the client details later on. This is supported both via the REST API and the Ory SDKs, as the
metadata
field is part of the client model definition in the API specification [source](https://raw.githubusercontent.com/ory/docs/master/docs/reference/api.json).
g
@chilly-king-10285 does the following hydra admin api returns the client's metadata as well ? /oauth2/auth/requests/login?login_challenge={login_challenge}
c
A message from kapa.ai
Based on the available knowledge sources, the Hydra Admin API endpoint
/admin/oauth2/auth/requests/login?login_challenge={login_challenge}
(or
/oauth2/auth/requests/login?login_challenge={login_challenge}
) returns detailed information about the ongoing login request, including a
client
object. This
client
object contains various fields describing the OAuth2 client, such as
client_id
,
client_name
,
redirect_uris
, and more. Importantly, the
client
object also includes a
metadata
field, which is described as: > "metadata": {"title": "JSONRawMessage represents a json.RawMessage that works well with JSON, SQL, and Swagger.", "type": "object"} This means that if you have stored custom information in the
metadata
field when creating the client, it will be included in the response from this endpoint. Here is an example structure from the API response:
Copy code
json {   "challenge": "...",   "client": {     "client_id": "...",     "client_name": "...",     "redirect_uris": [...],     "metadata": {       // your custom data here     },     ...   },   ... }
Therefore, yes, the Hydra Admin API returns the client's metadata as part of the
client
object in the login request response
 [Ory API Reference – getOAuth2LoginRequest](https://raw.githubusercontent.com/ory/docs/master/docs/reference/api.json).