> For the complete documentation index, see [llms.txt](https://docs.inrupt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inrupt.com/sdk/javascript-sdk/access-requests-and-grants/inspect-access-requests-and-access-grants.md).

# Inspect Access Requests and Access Grants

{% hint style="info" %}
**Access Requests and Grants**

The following Inrupt products are available to support Access Requests and Grants:

* **`solid-client-access-grants`** library for managing Access Requests and Grants
* Inrupt’s Enterprise Solid Server provides support for [Access Requests and Grants](/security/authorization/access-requests-grants.md). ESS serializes the Access Requests and Grants as Verifiable Credentials.
* Inrupt’s [Authorization Management Component](/security/authorization/access-requests-grants.md#authorization-management-component-amc) supports Access Request management.
  {% endhint %}

Since the content of this page is applicable to both Access Requests and Access Grants, the generic term Access Credential is used to refer to both.

Access Credentials are used to get access to data from a Pod, and it is useful to be able to inspect the metadata from the Credential to figure out which Pod data it applies to, and who can exercise the access it is giving.

## Reading information from Access Credentials

The **`@inrupt/solid-client-access-grants`** library provides various getters to extract information from the Access Credentials. The [API docs](https://inrupt.github.io/solid-client-access-grants-js/modules/common.html) lists all the available getters.

Most getters are specific to the Access Credentials data model: for instance, [getResources](https://inrupt.github.io/solid-client-access-grants-js/modules/common.html#getresources) lists all resources for which an Access Credential is applicable. Here is a basic usage exemple.

```javascript
const credential = /* get the credential */;
const resources = getResources(credential);
console.log(
  `Credential ${credential.id} applies to ${resources.length} resources.`
);
```

## Reading custom fields from Access Credentials

**`@inrupt/solid-client-access-grants`** supports adding custom fields to Access Credentials. These custom fields can also be read from the credential using dedicated getters. Two approaches are possible:

| Bulk reading custom fields with **`getCustomFields`**                                                                                       | Reads all the custom fields in the consent section of the provided Access Credential, and returns them as an object, keyed by custom field URL.                              |
| ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Reading typed individual custom fields with **`getCustomBoolean`**, **`getCustomFloat`**, **`getCustomInteger`** and **`getCustomString`**. | Reads a given custom field (using its URL as a key) from the consent section of the provided Access Credential. These getters are type-safe and will throw on type mismatch. |

```javascript
const accessRequest = await issueAccessRequest({/* ... */}, {
 /* ..., */
 customFields: new Set([
    {
      key: new URL("https://example.org/ns/customString"),
      value: "custom value",
    },
    {
      key: new URL("https://example.org/ns/customInteger"),
      value: 1,
    },
  ]),
});
const customFields = getCustomFields(accessRequest);
// s is "custom value"
const s = customFields["https://example.org/ns/customString"];
// i is 1
const i = customFields["https://example.org/ns/customInteger"];

// s2 is also "custom value", and it is type safe.
const s2: string = getCustomString(
  accessRequest,
  new URL("https://example.org/ns/customString")
);

// i2 is also 1, and it is type safe.
const i2: number = getCustomInteger(
  accessRequest,
  new URL("https://example.org/ns/customInteger")
);
```
