Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(DOCSP-39528): Consolidate User Metadata page #3344

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
You can read the user metadata of a currently logged-in user through the
:dotnet-sdk:`User <reference/Realms.Sync.User.html>` object.

The ``Profile`` property on the ``User`` object returns a
:dotnet-sdk:`UserProfile <reference/Realms.Sync.UserProfile.html>` object
of a logged-in user.

The following example shows how to get a user's email from the metadata.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
You can read the user metadata of a currently logged-in user through the
:flutter-sdk:`User <realm/User-class.html>` object.

The ``profile`` property on the ``User`` object returns a
:flutter-sdk:`User.profile <realm/User/profile.html>` object
of a logged-in user.

The following example shows how to get a user's email from the metatdata.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The selected language does not provide serializable user metadata. This
functionality is only available in Kotlin.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
You can read the user metadata of a currently logged-in user through that
user's ``User`` object.

To read the data, access the ``profile`` property on the ``User`` object
of a logged-in user.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
You can read the user metadata of a currently logged-in user through
that user's
:kotlin-sync-sdk:`User <io.realm.kotlin.mongodb/-user/index.html>`
object. You cannot edit user metadata through a ``User`` object.

To read the data, call the :kotlin-sync-sdk:`profileAsBsonDocument
<io.realm.kotlin.mongodb.ext/profile-as-bson-document.html>`
method on the ``User`` object of a logged-in user.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. versionadded:: 1.9.0

Kotlin SDK version 1.9.0 introduced an API that supports:

- A limited but stable EJSON encoder for user metadata returned by ``User.profileAsBsonDocument()``
- An experimental EJSON encoder that supports full document serialization for user
metadata returned by the :kotlin-sync-sdk:`User.profile()
<io.realm.kotlin.mongodb.ext/profile.html>` extension method. This encoder
and method requires experimental opt-in.

You must add the official
`Kotlin Serialization <https://github.com/Kotlin/kotlinx.serialization>`__
library to your project to use the Kotlin SDK's EJSON serialization.
For more information, refer to :ref:`Serialization <sdks-serialization>`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
You can read the user metadata of a currently logged-in user through that
user's ``User`` object.

To read the data, access the ``profile`` property on the ``User`` object
of a logged-in user.
13 changes: 0 additions & 13 deletions source/includes/configure-user-metadata.rst

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.. tabs-drivers::

tabs:
- id: csharp
content: |

.. literalinclude:: /examples/generated/dotnet/UserLinkExamples.snippet.user-metadata.cs
:language: csharp

- id: dart
content: |

.. literalinclude:: /examples/generated/flutter/authenticate_users_test.snippet.user-metadata.dart
:language: dart

- id: javascript
content: |

.. literalinclude:: /examples/generated/node/authenticate.snippet.user-metadata.js
:language: js

- id: kotlin
content: |

.. literalinclude:: /examples/generated/kotlin/AuthenticationTest.snippet.get-user-metadata.kt
:language: kotlin

- id: swift
content: |

.. literalinclude:: /examples/generated/code/start/Authenticate.snippet.read-user-metadata.swift
:language: swift

- id: typescript
content: |

.. literalinclude:: /examples/generated/node/authenticate.snippet.user-metadata.js
:language: js
6 changes: 0 additions & 6 deletions source/includes/update-user-metadata.rst

This file was deleted.

117 changes: 116 additions & 1 deletion source/sdk/users/user-metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,125 @@
User Metadata
=============

.. meta::
:description: Use Atlas Device SDK to read user metadata, such as email or birthday, from configured authentication providers.
:keywords: Realm, Flutter SDK, Kotlin SDK, .NET SDK, Node.js SDK, Swift SDK, code example

.. facet::
:name: genre
:values: reference

.. facet::
:name: programming_language
:values: csharp, dart, javascript/typescript, kotlin, swift

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol

Placeholder page for user metadata content.
.. tabs-selector:: drivers

This page describes how to manage user metadata for an authorized App
Services App user using Atlas Device SDK. For more information,
refer to :ref:`auth-provider-metadata` in the App Services documentation.

Atlas App Services can read **user metadata** from authentication providers,
such as Google or Facebook. Then, App Services exposes each user's metadata in
a field of their ``User`` object. For example, you might want to access a
user's name, email, birthday, or gender. This is read-only data that comes
from the third-party authentication provider.

This is distinct from maintaining your own, editable custom user data. If
you'd like to define your own user data fields, or have the ability to directly
update user data, use :ref:`sdks-custom-user-data`.

.. important:: Configure Metadata in Atlas

Before you can work with metadata provided by the authentication provider,
you must :ref:`configure metadata for the authentication provider
<configure-user-metadata-on-the-backend>`.

.. _sdks-read-user-metadata:

Read User Metadata
------------------

.. tabs-drivers::

.. tab::
:tabid: csharp

.. include:: /includes/api-details/csharp/users/user-metadata-read-user-metadata-description.rst

.. tab::
:tabid: dart

.. include:: /includes/api-details/dart/users/user-metadata-read-user-metadata-description.rst

.. tab::
:tabid: javascript

.. include:: /includes/api-details/javascript/users/user-metadata-read-user-metadata-js-ts-description.rst

.. tab::
:tabid: kotlin

.. include:: /includes/api-details/kotlin/users/user-metadata-read-user-metadata-description.rst

.. tab::
:tabid: swift

.. include:: /includes/api-details/swift/users/user-metadata-read-user-metadata-description.rst

.. tab::
:tabid: typescript

.. include:: /includes/api-details/javascript/users/user-metadata-read-user-metadata-js-ts-description.rst

.. include:: /includes/sdk-examples/users/user-metadata-read-user-metadata.rst

User metadata options vary depending on which provider you're using and
:ref:`which metadata fields you enable <configure-user-metadata-on-the-backend>`.

.. include:: /includes/stale-user-metadata.rst

.. _sdks-serializable-user-metadata:

Serializable User Metadata
~~~~~~~~~~~~~~~~~~~~~~~~~~

Some of the SDK languages provide serializers for user metadata.

.. tabs-drivers::

.. tab::
:tabid: csharp

.. include:: /includes/api-details/generic/users/user-metadata-serializable-user-metadata-not-supported.rst

.. tab::
:tabid: dart

.. include:: /includes/api-details/generic/users/user-metadata-serializable-user-metadata-not-supported.rst

.. tab::
:tabid: javascript

.. include:: /includes/api-details/generic/users/user-metadata-serializable-user-metadata-not-supported.rst

.. tab::
:tabid: kotlin

.. include:: /includes/api-details/kotlin/users/user-metadata-serializable-user-metadata-description.rst

.. tab::
:tabid: swift

.. include:: /includes/api-details/generic/users/user-metadata-serializable-user-metadata-not-supported.rst

.. tab::
:tabid: typescript

.. include:: /includes/api-details/generic/users/user-metadata-serializable-user-metadata-not-supported.rst
Loading