# The Client ID Document

An application identifies itself using a [client identifier (Client ID)](https://solid.github.io/solid-oidc/#clientids).

A Client ID can be:

* a URL that dereferences to a [Client ID Document](https://solid.github.io/solid-oidc/#clientids-document).
* a value that has been registered using either [OIDC dynamic or static registration](https://solid.github.io/solid-oidc/#clientids-oidc).

Inrupt’s [Javascript Client Libraries](/sdk/javascript-sdk.md) provide **`login`** APIs that can support the use of a Client ID that dereferences to a Client ID Document.

The Client ID Document is JSON-LD document that contains various metadata about the client.

### Perform Login with Client ID (of type URL)

{% hint style="info" %}
An application can host its JSON-LD document in any location; however, if possible, it is recommended that the application itself hosts the JSON-LD document as a static resource.
{% endhint %}

Inrupt’s client libraries provide **`login`** APIs that can support the use of a Client ID (of type URL) that dereferences to a Client ID Document. When calling the **`login()`** function, set the **`clientId`** option to the application’s Client ID.

For example, the following code snippet includes the application’s client ID **`https://my-app.example.com/myappid.jsonld`** to the **`login()`** function:

```javascript
// `login()` sends users to their Solid Identity Provider;
// Once logged in, returns users to the specified `redirectUrl`.
// Both the `redirectURL` and the `clientId` value must appear
// in the Client Identifier document located at the specified URL.
await login({
  oidcIssuer: "https://login.inrupt.com",      // Solid Identity Provider
  redirectUrl: "https://my-app.example.com/login/callback/", // Redirect back to application
  clientId: "https://my-app.example.com/myappid.jsonld"    // Client Identifier 
});
```

The Solid Identity Provider verifies the specified `clientId` and `redirectUrl` values with those found in the identifying JSON-LD document.

Once the login flow completes, the application includes both the user WebID and the application’s Client ID in its requests to the Solid Server. The Solid Server uses these identifiers to enforce access control.

{% hint style="info" %}
ESS OpenID Service caches the Client ID Document. As such, you may encounter an error if, within the caching period, you use the Client ID Document to log in, and later modify the Client ID Document and reuse the document for login.
{% endhint %}

### Client ID Document

The Resource found when dereferencing an application’s Client ID is a [JSON-LD document](https://solid.github.io/solid-oidc/#clientids-document) with:

* A **`@context`** value of **`https://www.w3.org/ns/solid/oidc-context.jsonld`**.
* Fields conformant to an [OIDC client registration](https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata).

For example, assume the following sample JSON-LD document may be found by dereferencing the Client ID **`https://my-app.example.com/myappid.jsonld`**:

<pre class="language-json"><code class="lang-json">{
  "@context": "https://www.w3.org/ns/solid/oidc-context.jsonld",
<strong>  "client_id": "https://my-app.example.com/myappid.jsonld",
</strong><strong>  "redirect_uris": [ "https://my-app.example.com/login/callback/" ],
</strong>  "client_name": "My Sample App",
  "client_uri": "https://my-app.example.com/",
  "logo_uri": "https://my-app.example.com/logo.png",
  "tos_uri": "https://my-app.example.com/terms.html",
  "policy_uri": "https://my-app.example.com/policy.html",
  "contacts": [
    "someone@example.com"
  ],
  "scope": "openid offline_access webid",
  "grant_types": [
    "refresh_token",
    "authorization_code"
  ]
}
</code></pre>

<table><thead><tr><th width="199.78839111328125">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong><code>@context</code></strong></td><td>The context for the JSON-LD document. The expected <code>@context</code> value is <code>https://www.w3.org/ns/solid/oidc-context.jsonld</code>.</td></tr><tr><td><strong><code>client_id</code></strong></td><td>A string containing the application’s Client Identifier. The <code>clientId</code> value passed to the <a href="https://inrupt.github.io/solid-client-authn-js/browser/functions.html#login">login()</a> function <mark style="color:red;"><strong>must</strong></mark> match the specified value exactly.</td></tr><tr><td><strong><code>redirect_uris</code></strong></td><td><p>An array containing URIs where the Solid Identity Provider may redirect the user to complete the login process, i.e., where the application’s <a href="https://inrupt.github.io/solid-client-authn-js/browser/functions.html#handleincomingredirect">handleIncomingRedirect()</a> will be called. The <code>redirectUrl</code> value passed to the <a href="https://inrupt.github.io/solid-client-authn-js/browser/functions.html#login">login()</a> function <mark style="color:red;"><strong>must</strong></mark> match one of the specified URIs exactly.</p><p>During development, to test with an application that is only running locally, you can specify the localhost url (e.g., <code>https://localhost:&#x3C;port>/</code> or <code>https://localhost:&#x3C;port>/some/login/callback/route/</code>) in both:</p><ul><li>the <code>redirect_uris</code> in the Client Identifier, and</li><li>the <code>redirectUrl</code> in the application’s <code>login()</code> call.</li></ul><p><mark style="color:red;"><strong>Remove</strong></mark> the localhost url from <code>redirect_uris</code> when you are running in production.</p></td></tr><tr><td><strong><code>scope</code></strong></td><td><p>A string containing a space-delimited list of OAuth2.0 scopes your application is allowed to request. OAuth2.0 scopes include:</p><p>Custom values may also be specified.</p></td></tr><tr><td>Scope</td><td>Notes</td></tr><tr><td><strong><code>openid</code></strong></td><td>If <strong><code>scope</code></strong> specified, <strong><code>openid</code></strong> is mandatory.</td></tr><tr><td><strong><code>offline_access</code></strong></td><td><p>Include <strong><code>offline_access</code></strong> to be issued refresh tokens.</p><p>For the definition of <strong><code>offline_access</code></strong> scope, see <a href="https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess">OpenID Connect</a>.</p></td></tr><tr><td><strong><code>webid</code></strong></td><td><strong><code>webid</code></strong> is <a href="https://solid.github.io/solid-oidc/#clientids-oidc">mandatory</a>.</td></tr><tr><td>Scope</td><td>Notes</td></tr><tr><td><strong><code>openid</code></strong></td><td>If <strong><code>scope</code></strong> specified, <strong><code>openid</code></strong> is mandatory.</td></tr><tr><td><strong><code>offline_access</code></strong></td><td><p>Include <strong><code>offline_access</code></strong> to be issued refresh tokens.</p><p>For the definition of <strong><code>offline_access</code></strong> scope, see <a href="https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess">OpenID Connect</a>.</p></td></tr><tr><td><strong><code>webid</code></strong></td><td><strong><code>webid</code></strong> is <a href="https://solid.github.io/solid-oidc/#clientids-oidc">mandatory</a>.</td></tr><tr><td><strong><code>grant_types</code></strong></td><td><p>An array of OAuth 2.0 grant types that the client can use at the authorization server’s token endpoint.</p><p>For additional values, see the <strong><code>grant_types</code></strong> definition in <a href="https://datatracker.ietf.org/doc/html/rfc7591#section-2">https://datatracker.ietf.org/doc/html/rfc7591#section-2</a>.</p></td></tr><tr><td></td><td></td></tr><tr><td><strong><code>"authorization_code"</code></strong></td><td>The default authentication flow, based on redirections between the application and the Solid Identity Provider.</td></tr><tr><td><strong><code>"refresh_token"</code></strong></td><td><p>The flow where a refresh token is used to “refresh” an expired session.</p><p>Used for apps that have declared the <a href="#scope-offline-access">offline_access</a> scope (i.e., discouraged for in-browser apps).</p></td></tr><tr><td></td><td></td></tr><tr><td><strong><code>"authorization_code"</code></strong></td><td>The default authentication flow, based on redirections between the application and the Solid Identity Provider.</td></tr><tr><td><strong><code>"refresh_token"</code></strong></td><td><p>The flow where a refresh token is used to “refresh” an expired session.</p><p>Used for apps that have declared the <a href="#scope-offline-access">offline_access</a> scope (i.e., discouraged for in-browser apps).</p></td></tr><tr><td><strong><code>client_name</code></strong></td><td>Optional. A string containing a user-friendly name for the application.</td></tr><tr><td><strong><code>client_uri</code></strong></td><td>Optional. A string containing the application’s homepage URI.</td></tr><tr><td><strong><code>logo_uri</code></strong></td><td>Optional. A string containing the URI where the application’s logo is available.</td></tr><tr><td><strong><code>tos_uri</code></strong></td><td>Optional. A string containing the URI where the application’s terms of service are available.</td></tr><tr><td><strong><code>policy_uri</code></strong></td><td>Optional. A string containing the URI where the application’s privacy policy is available.</td></tr><tr><td><strong><code>contacts</code></strong></td><td>Optional. An array of contact information for the application.</td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="198.83740234375"></th><th></th></tr></thead><tbody><tr><td><strong><code>"authorization_code"</code></strong></td><td>The default authentication flow, based on redirections between the application and the Solid Identity Provider.</td></tr><tr><td><strong><code>"refresh_token"</code></strong></td><td><p>The flow where a refresh token is used to “refresh” an expired session.</p><p>Used for apps that have declared the <a href="#scope-offline-access">offline_access</a> scope (i.e., discouraged for in-browser apps).</p></td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="159.4730224609375">Scope</th><th>Notes</th></tr></thead><tbody><tr><td><strong><code>openid</code></strong></td><td>If <strong><code>scope</code></strong> specified, <strong><code>openid</code></strong> is mandatory.</td></tr><tr><td><strong><code>offline_access</code></strong></td><td><p>Include <strong><code>offline_access</code></strong> to be issued refresh tokens.</p><p>For the definition of <strong><code>offline_access</code></strong> scope, see <a href="https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess">OpenID Connect</a>.</p></td></tr><tr><td><strong><code>webid</code></strong></td><td><strong><code>webid</code></strong> is <a href="https://solid.github.io/solid-oidc/#clientids-oidc">mandatory</a>.</td></tr></tbody></table>

{% hint style="info" %}
For additional fields to include in the document as well as more information on the aforementioned fields, see [RFC7591](https://datatracker.ietf.org/doc/html/rfc7591#section-2).
{% endhint %}

See also:

* [Solid-OIDC specification: Client Identifiers](https://solid.github.io/solid-oidc/#clientids).
* [OAuth2.0 website](https://www.oauth.com/)
* [OpenID Connect (OIDC) Dynamic Client Registration](https://openid.net/specs/openid-connect-registration-1_0.html)
* [Solid OIDC Primer](https://solid.github.io/solid-oidc/primer/)

#### Hosting Client ID Document

*Recommended* Although an application can host its JSON-LD document in any location, it is recommended that the application itself hosts the JSON-LD document as a static resource if possible.

#### Redirect URI Value During Development

During development, to test with an application running only on localhost, specify the localhost url (e.g., **`https://localhost:<port>/`** or **`https://localhost:<port>/some/login/callback/route/`**) as the redirect url in the Client ID Document and the application; i.e.,

* the **`redirect_uris`** in the Client ID Document,

  <pre class="language-json"><code class="lang-json">{
    "@context": "https://www.w3.org/ns/solid/oidc-context.jsonld",
    "client_id": "https://my-app.example.com/myappid",
  <strong>  "redirect_uris": ["http://localhost:3000/"],
  </strong>  "client_name": "My Test App",
    "client_uri": "https://my-app.example.com/",
    "logo_uri": "https://my-app.example.com/logo.png",
    "tos_uri": "https://my-app.example.com/terms.html",
    "policy_uri": "https://my-app.example.com/policy.html",
    "scope" : "openid offline_access webid",
    "grant_types" : ["refresh_token","authorization_code"]
  }
  </code></pre>
* the **`redirectUrl`** in the application’s **`login()`** call.

  <pre class="language-javascript"><code class="lang-javascript">await login({
    oidcIssuer: 'https://login.inrupt.com',
    clientId: 'https://my-app.example.com/myappid',
  <strong>  redirectUrl: 'http://localhost:3000/'
  </strong>});
  </code></pre>

{% hint style="warning" %} <mark style="color:red;">**Remove**</mark> the localhost url from **`redirect_uris`** when you are running in production.
{% endhint %}

{% hint style="info" %}
ESS OpenID Service caches the Client ID Document. As such, you may encounter an error if, within the caching period, you use the Client ID Document to log in, and later modify the Client ID Document and reuse the document for login.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.inrupt.com/guides/identity-in-solid/the-client-id-document.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
