AUTH Metadata

Auth Metadata #

Metadata Fields serve to define the meta field information present in the authenticating JWT token for each user. These fields hold pertinent details related to MongoDB Realm JWT providers, and for in-depth insights, developers can refer to the following link: MongoDB JWT Meta Data Fields.

Every time a user logs in, metadata is employed to store information about them, and it is refreshed in the Realm database. This data finds its abode within the User Object of the logged-in user in Realm. Within server functions, developers can access this metadata from the data property of the user object. Moreover, the metadata is also stored in the JWT token. How to read meta data within a MongoDB App Services application is explained here.

To configure metadata fields in the CoSync Auth portal, developers must specify each field using a path and a field name. The path employs dot notation to indicate the full path of the embedded JSON object within the JWT token. The field name, on the other hand, designates how the metadata field appears in the data property of the Realm user object. Additionally, developers have the option to designate whether a metadata field is required or not. To successfully onboard with CoSync Auth, users must ensure all required metadata fields are properly specified.

For the Apple and Google social sign-in protocols, the developer has the ability to retrieve the user’s first and last name from the credentials provided by Apple Id or the Google GIDSignIn current user. This information can then be incorporated into the metadata structure when creating a new account.

Auth Signup Metadata #

As an illustration, let’s consider a scenario where the developer wishes to gather the user’s first and last names during the signup process. To achieve this, the developer can set up these details as metadata field requirements, as demonstrated below:


In the event that the developer desires to permit users to modify their first and last names from the Profile section of the application’s UI, it is imperative to designate these metadata fields as editable. Thankfully, the CoSync Portal offers a user-friendly interface to facilitate the specification of metadata field structures.

From an API perspective, it’s important to note that the type for these metadata fields is always a string, regardless of the data collected. This consistency ensures a seamless and straightforward integration for developers handling metadata information.

Auth Invite Metadata #

Beyond the scope of Signup metadata, the CoSync Auth authentication system extends its support to embrace Invite metadata. This specialized metadata is delivered through the invite onboarding mechanism to the application. For instance, invite metadata might encompass valuable information such as a discount coupon exclusively intended for new users invited to join the application.

To facilitate this, developers can specify a coupon metadata field for the application, as exemplified below: