Check permissions before you enable a feature
Read the granted scopes from each token response and enable only the features that those scopes allow.
Run these steps after every login. The issued grant can lack a scope that the client configures. For the grant model, see App permissions.
Prerequisites
- A token response from a completed login.
- A list of the scope that each feature of your app needs, from the scope reference.
Warning: Never show a requested scope as granted. Only the token response shows the grant.
Steps
- Read the
scopefield of the token response. - If the field lists the scope of a feature, enable that feature.
- If the field does not list the scope, disable the feature.
- Show the user which permission the disabled feature needs.
- If the response has no
scopefield, read the validated grant information of your OpenID Connect (OIDC) library. - If an API call returns
403 insufficient_scope, disable the affected feature. - Check the scope selection of the client in the developer portal.
- After the client configuration changes, start another login.
- Read the
scopefield of the fresh token response.
Result
Your app enables a feature only when the token grants its scope. The account, unrelated features, and drafts stay available while a permission is missing.
Release checks
These cases test the permission handling of your app before release:
- The user cancels consent.
- The token response omits a scope that the client configures.
- An API call returns
insufficient_scope. - A token expires while the user moves between pages.
- The user logs out of your app, then logs in with a different account.
- Each control works with a keyboard, with touch, and with a screen reader.
