Skip to main content
import { B2BIdentityProvider } from '@stytch/nextjs/b2b';

const isProfileScope = (scope) => scope === 'openid' || scope === 'email' || scope === 'profile';
const isDataScope = (scope) => !isProfileScope(scope);

const getScopeDescription = (scope) => {
  switch (scope) {
    case 'openid':
      return 'Your account ID';
    case 'email':
      return 'Your email address';
    case 'profile':
      return 'Your name and profile';
    case 'read:data':
      return 'Read access to your data';
    case 'write:data':
      return 'Write access to your data';
    default:
      return `The ${scope} permission`;
  }
};

const getManifest = ({ scopes, clientName }) => [
  {
    header: `${clientName} wants to view your Profile`,
    items: [
      {
        text: 'View information stored in your Profile about your account and your user.',
        details: scopes.filter(isProfileScope).map(getScopeDescription),
      },
    ],
  },
  {
    header: `${clientName} wants to access your Data`,
    items: scopes.filter(isDataScope).map(getScopeDescription),
  },
];

const presentation = { theme: { 'font-family': 'Arial' } };

const IdentityProviderPage = () => {
  return <B2BIdentityProvider presentation={presentation} getIDPConsentManifest={getManifest} />;
};

export default IdentityProviderPage;
If your project has Custom Scopes configured, the Consent UI can be customized via the getIDPConsentManifest prop. Supply a custom manifest for fine-grained control over the wording used and grouping of the permissions being requested. If no getIDPConsentManifest function is defined, the description field for each scope will be used instead. To see all authentication and customization options, see the UI configuration props.