Scopes and claims
Every scope a onefold application can request, the claims each one returns in the ID token and from userinfo, and how scopes relate to consent.
A scope is a permission your application asks a user for. A claim is one piece of information onefold returns about that user. The scopes a user grants decide which claims you can read. This page is the reference for both.
Scopes
| Scope | What it grants | How you enable it |
|---|---|---|
openid | An ID token, and the OpenID Connect userinfo endpoint | Always available. Request it; there is nothing to switch on. |
identity | Username, email address, verification status, display name and date of birth | The Identity switch on the application's OAuth2 tab. On by default. |
profile | Username, display name, avatar and other profile details | The Profile switch on the OAuth2 tab |
socials:<provider> | Data from the user's account at a social provider, for example socials:github | Configure the provider first. See Social login. |
Rules:
- Send scopes space-separated in the
scopeparameter of the authorization request. - A request for a scope that is not enabled for the application fails with
invalid_scope. - Every scope is read-only. No scope lets your application change an account.
- Without
openid, the flow is plain OAuth 2.0: you receive an access token and a refresh token, no ID token, and/o/userinfo/refuses the access token. Use/api/v1/userinfo/instead.
Claims from userinfo
Call GET /o/userinfo/ or GET /api/v1/userinfo/ with the access token. Both return the same
claims.
| Claim | Type | Returned with | Meaning |
|---|---|---|---|
sub | string | Always | The user's ID. Stable for the life of the account. |
id | string | Always | The same value as sub |
username | string | identity or profile | The user's username. It can change. |
preferred_username | string | identity or profile | The same value as username, under its OpenID Connect name |
is_verified | boolean | identity or profile | Whether the user has verified their email address |
email | string | identity | The user's email address. It can change. |
email_verified | boolean | identity | The same value as is_verified, under its OpenID Connect name |
date_joined | string | profile | When the account was created, as an ISO 8601 timestamp |
name | string | identity or profile | The display name. Absent when the user has not set one. |
birthdate | string | identity | The date of birth, as YYYY-MM-DD. Absent when the user has not given one. |
given_name | string | profile | The first name. Absent when the user has not set one. |
middle_name | string | profile | The middle name. Absent when the user has not set one. |
family_name | string | profile | The last name. Absent when the user has not set one. |
nickname | string | profile | Absent when the user has not set one. |
website | string | profile | An https URL. Absent when the user has not set one. |
updated_at | number | profile | When the profile last changed, in seconds since the epoch |
locale | string | A claims request | The user's language. Returned only when you ask for it and the user approves (below). |
picture | string | profile | The avatar URL. Always present with profile: a user with no uploaded avatar has a generated one. |
gender | string | profile | male, female or prefer_not_to_say, as listed in the userinfo reference. Absent when the user has not answered. |
banner_url | string | profile | The banner URL. Absent when the user has not uploaded one. |
<provider> | object | socials:<provider> | The provider block, below |
A token granted only openid returns sub and id and nothing else.
is_verified and email_verified are one fact under two names and never differ.
A provider block
One block per social provider scope the user granted, keyed by the provider's name:
{
"github": {
"scopes": ["read:user"],
"data": { "…": "…" },
"expired": false
}
}| Field | Meaning |
|---|---|
scopes | The provider's own scopes the user approved |
data | What the provider returned. Its shape is the provider's. |
expired | true when onefold could not refresh the provider's data, for example because the user revoked access at the provider. Treat data as stale. |
Social login covers the supported providers and their configuration.
Claims in the ID token
The ID token carries less than userinfo: identification only.
| Claim | Present |
|---|---|
sub, iss, aud, exp, iat, auth_time | Always |
acr | Always. "1" for a sign-in with one factor, "2" when the user also verified a second factor. |
preferred_username, email, email_verified | With the identity scope |
nonce | When you sent one |
Profile claims and provider blocks are never in the ID token. Read them from userinfo. Verify the ID token covers the checks to make.
The same claims in the management API
The management API returns the same claims for a user as userinfo does, limited to the scopes that user granted your application.
Request individual claims
To ask for a claim your scopes do not return, send the OpenID Connect claims parameter on
the authorization request, naming the claim under userinfo:
{ "userinfo": { "locale": null } }The user approves it on the consent screen together with the scopes, and userinfo then
returns it. A user who approved an earlier request sees the consent screen again when a new
request asks for a claim they have not approved. Only the userinfo member is read: the ID
token's claims do not change, and a claim onefold does not serve is ignored.
Scopes and consent
The consent screen lists one line per requested scope, and the user approves or declines the
request as a whole. A user cannot approve some scopes and decline others. openid and
identity share one line, "Confirm your identity.", which the screen shows once.
Request only the scopes you use: each one is a line the user reads before deciding. See Consent screen.
Tokens and sessions
The ID token, access token and refresh token onefold issues, how long each lasts, and how they relate to your session and the user's onefold session.
Organizations and roles
How a onefold organization lets several developers own and manage applications together, how roles and permissions decide what each member may do, and what an organization does not do.