Skip to content

Consent screen

The OAuth consent screen every site shows an app asking for access, and its permission list.

<div data-mount="published"></div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/consent.css";

Usage

import { Form } from "react-router";
import { ConsentScreen } from "capsomer/react/consent";
import "capsomer/consent.css";
<ConsentScreen client={c.clientName} product="Example Co" publishedBy={c.publishedBy} redirectHost={c.redirectHost}
  account={{ name: c.accountName, email: c.email }} can={READS} write={{ items: WRITES, scope: "example.write" }}
  hidden={{ client_id: c.clientId, redirect_uri: c.redirectUri, state: c.state }} Form={Form} />

Examples

A client that registered itself, a loopback warning and a refusal

<div data-mount="registered"></div>

A request that cannot be shown

<div data-mount="refused"></div>

Permission lists: allowed and never

<div data-mount="lists"></div>

API reference

PermissionList

PropTypeRequiredDoes
idstringYes
headingReactNodeYes
itemsreadonly ReactNode[]Yes
allowedbooleanYesA list of what is allowed (checks) or of what is not (crosses).

ConsentScreen

PropTypeRequiredDoes
clientstringYesThe app asking: "Example Assistant".
productstringYesThe site's name: "Example Co".
publishedBystring | nullA client vouched for by a host that publishes its metadata names that host; a client that registered itself has only its own claim to its name, and the screen says so.
redirectHoststringYesWhere the access will be sent: the redirect's host.
redirectWarningReactNodeA redirect that is not the client's own (a localhost loopback, a host unlike the name).
account{ name: ReactNode; email?: ReactNode }Yes
canreadonly ReactNode[]YesWhat it can do once allowed.
write{ items: readonly ReactNode[]; scope?: string; defaultChecked?: boolean; name?: string }The write grant, a separate choice: what it adds, its scope name, ticked by default when asked.
errorReactNodeThe last post's refusal.
hiddenRecord<string, string | undefined>YesThe OAuth request, carried through the post.
submitting"allow" | "deny" | nullWhich button the person pressed, while the post is under way.
brandReactNodeThe site's mark or wordmark at the top.
footnoteReactNodeA last line: "Example Co never shares your payment provider's token with other apps."
FormFormComponentThe router's form (React Router's Form), for its pending state. Default a plain form.

ConsentRefusal

PropTypeRequiredDoes
titleReactNodeYes
childrenReactNodeYes

Parts and data attributes

ClassIs
.cap-consentthe root
.cap-consent-accounta part
.cap-consent-actionsa part
.cap-consent-bodya part
.cap-consent-boxa part
.cap-consent-branda part
.cap-consent-foota part
.cap-consent-forma part
.cap-consent-linea part
.cap-consent-monoa part
.cap-consent-texta part
.cap-consent-titlea part
.cap-permissionsits own class
.cap-permissions-headingits own class
.cap-permissions-listits own class
AttributeValues
data-allowedpresent or absent
StateRead from
:focusthe platform

Accessibility

KeyDoes
TabThe write grant's checkbox, Allow access, Deny
SpaceTicks the write grant
Enter on a buttonPosts the choice
  • One main, one h1 that names the client and the product.
  • The permission list is named by its heading; its check or cross is hidden, the heading says which list it is.
  • A refusal is an alert.