How to Create a Paywall or Restrict Usage to an App for Subscribed Users Only
Last Updated:
Overview
Solution
By creating a role for paid subscribers and adding permissions to that role, applications can be configured to deny access unless a user has the correct role/permissions. Upon login Auth0 authenticates and authorizes the user and includes the permissions in the returned Access Token. Then, the application can inspects the token to learn what access this user can have.
Another fallback option to RBAC could be with user based metadata. For each subscriber, have an app_metadata value like subscriber=true. When someone takes out a valid subscription, make a call to the /patch-users-by-id endpoint of the Management API and set the metadata value.
To block access to applications for users that do not have the metadata value, use a Post Login Action and api.access.deny(). An example of blocking access can be found here: Access Control . The Action can be created in the Auth0 dashboard and configured to look for the metadata value and deny access if it does not exist.
Related References: