scope parameter - a space-delimited list of capabilities that Connected App wishes to be granted. Clients should request access tokens with the minimal set of capabilities required for that client to function.
For example, a client may need “read” access to a user’s resources, but doesn’t need to update resources. This client should request only read-only access, and obtain an access token that cannot be used to update resources.
A Connected App Client can request a token with the scope of openid profile read:data as shown:
scope field representing the capabilities granted to the token.
Built-in Scopes
Built-in scopes are preconfigured scopes within the Stytch platform.Built-in OIDC Scopes
The Stytch platform supports all scopes defined by the OpenID Connect Core specification with no prior configuration required. These scopes control whether an ID Token (for B2B, for Consumer) is granted to the Connected App, and what claims are present in the ID Token and in theUserInfo API response (for B2B, for Consumer).
| Name | Effect when granted |
|---|---|
openid | An OIDC id_token will be returned from the /oauth2/token endpoint |
email | The email and email_verified claims will be returned in the id_token |
phone | The phone_number and phone_number_verified claims will be returned in the id_token |
profile | The name, given_name, middle_name, family_name, picture, and locale claims will be returned in the id_token |
| Name | Effect when granted |
|---|---|
offline_access | A refresh_token will be returned from the /oauth2/token endpoint for use in subsequent refresh token flows |
Built-in Stytch Platform Scopes
The Stytch platform supports additional scopes used for specific actions in the Stytch API. First Party OAuth clients can request thefull_access scope to enable access to the Exchange Access Token endpoint (for B2B, for Consumer).
| Name | Effect when granted |
|---|---|
full_access | Enables the Exchange Access Token API call |
Custom Scopes
Your application can additionally define custom scopes tied to your RBAC (Role-Based Access Control) system (for B2B, for Consumer). Create custom scopes to support the different use-casesDefining Custom Scopes
Your application’s RBAC policy is managed in the Stytch RBAC dashboard. Before defining custom scopes, you must define Resources (for B2B, for Consumer) for those scopes to act on. Each resource has a set of actions that can be performed upon that resource. Scopes are then composed of permissions, where each permission is anaction applied to a resource.
For example, given the resources of:
readonly:content, read:*, and content:readonly are all allowed).
What custom scopes can be granted?
The end user authorizing the application can only grant scopes that correspond to permissions they themselves possess:- Permissions can be spread across multiple roles.
- Grantable scopes are determined by checking if the union of the user’s roles covers all required permissions.
- Scope
write:datarequireswritepermission on bothdocumentsandimages - End User Roles:
document_manager➔ grantswriteondocumentsimage_uploader➔ grantswriteonimages
Consent screen customization
By default, the consent screen will show thedescription of each scope being requested. The consent screen can be tailored using the getIDPConsentManifest SDK callback. Use this callback to group scopes by logical domain, provide additional documentation, or otherwise customize the language displayed to the end user.
Access Token Scope Validation
Many Access Token JWT libraries will check for a particular scope within the token before letting the call proceed. While this approach is satisfactory for many applications, applications with complex RBAC requirements should check for the underlying permission that the scope grants instead. Authorizing at the permission level instead of the scope level creates a level of abstraction that makes it easier to introduce new scopes, or change the permissions attached to a scope over time. For example, both thewrite:data and the data:* scope grant permission to write to a document. Checking for the underlying permission makes it easier to add new scopes (e.g. documents:*) in the future without requiring application code changes.
Use the Stytch SDK Authenticate Access Token method: