---
title: "useAgentConsent"
description: "useAgentConsent, auto-imported in the app: its options, return value and types."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/use-agent-consent"
---
# useAgentConsent

## Interfaces

### AgentConsentRequest

Defined in: [src/runtime/vue/composables/use-agent-consent.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts)

What an agent asks for, as the server stored it — never as its URL says.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="clientid">
        
      </a>
      
       <code>
        clientId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="clientname">
        
      </a>
      
       <code>
        clientName
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      The name the agent registered under: self-declared, never verified.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="redirecthost">
        
      </a>
      
       <code>
        redirectHost
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The host approving sends the browser (and the authorization code) to.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="scopes">
        
      </a>
      
       <code>
        scopes
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      Every scope the agent asked for.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="expiresat">
        
      </a>
      
       <code>
        expiresAt
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      When the request lapses, in epoch milliseconds.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UseAgentConsentReturn

Defined in: [src/runtime/vue/composables/use-agent-consent.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="request">
        
      </a>
      
       <code>
        request
      </code>
    </td>
    
    <td>
      <code>
        Ref
      </code>
      
      <<a href="#agentconsentrequest">
        <code>
          AgentConsentRequest
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="state">
        
      </a>
      
       <code>
        state
      </code>
    </td>
    
    <td>
      <code>
        Ref
      </code>
      
      <<a href="#agentconsentstate">
        <code>
          AgentConsentState
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ispending">
        
      </a>
      
       <code>
        isPending
      </code>
    </td>
    
    <td>
      <code>
        Ref
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      <code>
        true
      </code>
      
       while an answer is being sent.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="error">
        
      </a>
      
       <code>
        error
      </code>
    </td>
    
    <td>
      <code>
        Ref
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Message of the last failure; cleared when the next answer starts.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="approve">
        
      </a>
      
       <code>
        approve
      </code>
    </td>
    
    <td>
      () => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Grant the request and send the browser back to the agent. Throws on failure.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="deny">
        
      </a>
      
       <code>
        deny
      </code>
    </td>
    
    <td>
      () => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Refuse the request and send the browser back to the agent with <code>
        access_denied
      </code>
      
      . Throws on failure.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts" rel="nofollow">
        src/runtime/vue/composables/use-agent-consent.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Type Aliases

### AgentConsentState

```ts
type AgentConsentState = "loading" | "ready" | "missing" | "answered";
```

Defined in: [src/runtime/vue/composables/use-agent-consent.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts)

`loading` until the request is read; `ready` to decide; `missing` when it
expired, was already answered or belongs to another account; `answered`
once the browser is on its way back to the agent.

## Functions

### useAgentConsent()

```ts
function useAgentConsent(): UseAgentConsentReturn;
```

Defined in: [src/runtime/vue/composables/use-agent-consent.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-agent-consent.ts)

The consent step of an agent's authorization: loads what the agent asks
for from the server (its self-declared name, where approving redirects,
every scope) and answers it. The page it runs on is where the OAuth
provider sends every authorization (`pages.agentConsent`, `/oauth/consent`
by default); `<AgentConsent>` is the ready-made UI over it.

#### Returns

[`UseAgentConsentReturn`](#useagentconsentreturn)


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
