Skip to Content
Xeonr Developer Docs
Guides

What the person grants

The consent screen lets a person narrow your request. Mark the scopes you cannot work without with required_scope, and read the granted scope and authorization_details from the token response.

On the consent screen at https://auth.xeonr.io/auth/authorize, the person signing in decides what your application gets. They may narrow your request, but never widen it:

  • Untick scopes. Any scope you asked for can be unticked, except openid and the scopes you name in required_scope.
  • Narrow the resources you pushed. If your request carried authorization_details, the person can drop some of those resources, or some of the actions on them. At least one resource of each application stays while any of that application's scopes is granted.
  • Limit the grant to resources. If you asked for a product's scopes with no authorization_details for that product, the person can limit the grant to specific resources of that product: for example, only the branchd group acme or the repository acme/api. The "Limit to…" choice is offered for each product whose resource types are enforced, and only with response_type=code.

So the token you get may carry fewer scopes than you asked for, and may carry authorization_details you did not send. Read both from the token response. Never assume your request was granted as sent.

This applies to the browser consent screen of the Authorization Code flow, with or without PAR.


Marking scopes as required: required_scope

required_scope is a space-separated list of scopes, each of which must also be in scope. The consent screen shows them without a checkbox, so the person can allow them or deny the whole request, but not untick them. openid is always required when you ask for it.

Use it for the scopes your application cannot work without, and leave optional features out of it so the person can decline them.

Send it on the authorize URL:

https://auth.xeonr.io/auth/authorize
  ?response_type=code
  &client_id=550e8400-e29b-41d4-a716-446655440000
  &redirect_uri=https%3A%2F%2Fmyapp.example.com%2Fcallback
  &scope=openid%20profile%20forge%3Acontents%3Aread%20forge%3Apull-request%3Aedit
  &required_scope=forge%3Acontents%3Aread
  &state=abc123

or in a pushed request (POST /api/v1/oauth/par), alongside scope. A pushed request that names a required_scope outside its scope is refused:

{
  "error": "invalid_request",
  "error_description": "required_scope \"forge:contents:read\" is not in scope"
}

When you use PAR, the pushed required_scope is the one that counts. Any required_scope on the front-channel URL is ignored.


Reading what was granted

The token response of the authorization_code grant, and of every later refresh_token grant, carries:

FieldWhat it is
scopeThe scopes the person kept, space-separated. Fewer than you asked for if they unticked some.
authorization_detailsThe resources the token is limited to (RFC 9396 §7). Present only when there are any: the details you pushed, as narrowed, or the resources the person limited the grant to.
{
  "access_token": "eyJ...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "eyJ...",
  "scope": "openid profile forge:contents:read",
  "authorization_details": [
    {
      "type": "forge:repository",
      "identifier": "acme/api",
      "actions": ["forge:contents:read"]
    }
  ]
}

A resource the person limited the grant to is always written as type, identifier and actions:

FieldMeaning
type<application slug>:<resource type>, such as forge:group or forge:repository
identifierThe resource, in the product's own form, such as acme or acme/api
actionsThe scopes allowed on that resource. Each one is a granted scope, or one a granted scope implies (read ⊂ edit ⊂ admin).

The same authorization_details are in the access token's authorization_details claim (Access Token Anatomy) and in the introspection response.

What to do with it

  • Check the scopes before you use a feature. If a scope you need for an optional feature is missing, turn the feature off, or explain why it needs that scope and send the person through consent again.
  • Expect resource limits. A token with authorization_details reaches only those resources. The product refuses anything outside them, even where the person's own access would allow it. Show the person what the token is limited to rather than failing on the first refusal.
  • Do not cache your request as the grant. Store the scope and authorization_details from the token response. They stay the same on refresh.

On this page