Skip to content

Commit 3c38bc1

Browse files
authored
(DOCSP-39528): Consolidate User Metadata page (#3344)
## Pull Request Info - SDK Docs Consolidation Jira ticket: https://jira.mongodb.org/browse/DOCSP-39528 *Staged Page* - [User Metadata](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39528/sdk/users/user-metadata/) *Page Source* Add links to every SDK's pages where you got the SDK-specific information: - [Flutter: User Metadata](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/users/user-metadata/) - [Kotlin: Manage User Metadata](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/users/user-metadata/) - [.NET: User Metadata](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/manage-users/user-metadata/) - [Node.js: User Metadata](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/users/user-metadata/) - [Swift: User Metadata](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/users/user-metadata/) ### PR Author Checklist Before requesting a review for your PR, please check these items: - [x] Open the PR against the `feature-consolidated-sdk-docs` branch instead of `master` - [x] Tag the consolidated page for: - genre - meta.keywords - meta.description #### Naming - [x] Update Realm naming and the language around persistence layer/local/device per [this document](https://docs.google.com/document/d/126OczVxBWAwZ4P5ZsSM29WI3REvONEr1ald-mAwPtyQ/edit?usp=sharing) - [x] Include `.rst` files comply with [the naming guidelines](https://docs.google.com/document/d/1h8cr66zoEVeXytVfvDxlCSsUS5IZwvUQvfSCEXNMpek/edit#heading=h.ulh8b5f2hu9) #### Links and Refs - [x] Create new consolidated SDK ref targets starting with "_sdks-" for relevant sections - [x] Remove or update any SDK-specific refs to use the new consolidated SDK ref targets - [x] [Update any Kotlin API links](https://jira.mongodb.org/browse/DOCSP-32519) to use the new Kotlin SDK roles #### Content - [x] Shared code boxes have snippets or placeholders for all 9 languages - [x] API description sections have API details or a generic placeholder for all 9 languages - [x] Check related pages for relevant content to include - [x] Create a ticket for missing examples in each relevant SDK: Consolidation Gaps epic ### Reviewer Checklist As a reviewer, please check these items: - [ ] Shared code example boxes contain language-specific snippets or placeholders for every language - [ ] API reference details contain working API reference links or generic content - [ ] Realm naming/language has been updated - [ ] All relevant content from individual SDK pages is present on the consolidated page
1 parent c92d7f9 commit 3c38bc1

11 files changed

+204
-20
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
You can read the user metadata of a currently logged-in user through the
2+
:dotnet-sdk:`User <reference/Realms.Sync.User.html>` object.
3+
4+
The ``Profile`` property on the ``User`` object returns a
5+
:dotnet-sdk:`UserProfile <reference/Realms.Sync.UserProfile.html>` object
6+
of a logged-in user.
7+
8+
The following example shows how to get a user's email from the metadata.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
You can read the user metadata of a currently logged-in user through the
2+
:flutter-sdk:`User <realm/User-class.html>` object.
3+
4+
The ``profile`` property on the ``User`` object returns a
5+
:flutter-sdk:`User.profile <realm/User/profile.html>` object
6+
of a logged-in user.
7+
8+
The following example shows how to get a user's email from the metatdata.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The selected language does not provide serializable user metadata. This
2+
functionality is only available in Kotlin.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
You can read the user metadata of a currently logged-in user through that
2+
user's ``User`` object.
3+
4+
To read the data, access the ``profile`` property on the ``User`` object
5+
of a logged-in user.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
You can read the user metadata of a currently logged-in user through
2+
that user's
3+
:kotlin-sync-sdk:`User <io.realm.kotlin.mongodb/-user/index.html>`
4+
object. You cannot edit user metadata through a ``User`` object.
5+
6+
To read the data, call the :kotlin-sync-sdk:`profileAsBsonDocument
7+
<io.realm.kotlin.mongodb.ext/profile-as-bson-document.html>`
8+
method on the ``User`` object of a logged-in user.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. versionadded:: 1.9.0
2+
3+
Kotlin SDK version 1.9.0 introduced an API that supports:
4+
5+
- A limited but stable EJSON encoder for user metadata returned by ``User.profileAsBsonDocument()``
6+
- An experimental EJSON encoder that supports full document serialization for user
7+
metadata returned by the :kotlin-sync-sdk:`User.profile()
8+
<io.realm.kotlin.mongodb.ext/profile.html>` extension method. This encoder
9+
and method requires experimental opt-in.
10+
11+
You must add the official
12+
`Kotlin Serialization <https://github.com/Kotlin/kotlinx.serialization>`__
13+
library to your project to use the Kotlin SDK's EJSON serialization.
14+
For more information, refer to :ref:`Serialization <sdks-serialization>`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
You can read the user metadata of a currently logged-in user through that
2+
user's ``User`` object.
3+
4+
To read the data, access the ``profile`` property on the ``User`` object
5+
of a logged-in user.

source/includes/configure-user-metadata.rst

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: csharp
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/dotnet/UserLinkExamples.snippet.user-metadata.cs
8+
:language: csharp
9+
10+
- id: dart
11+
content: |
12+
13+
.. literalinclude:: /examples/generated/flutter/authenticate_users_test.snippet.user-metadata.dart
14+
:language: dart
15+
16+
- id: javascript
17+
content: |
18+
19+
.. literalinclude:: /examples/generated/node/authenticate.snippet.user-metadata.js
20+
:language: js
21+
22+
- id: kotlin
23+
content: |
24+
25+
.. literalinclude:: /examples/generated/kotlin/AuthenticationTest.snippet.get-user-metadata.kt
26+
:language: kotlin
27+
28+
- id: swift
29+
content: |
30+
31+
.. literalinclude:: /examples/generated/code/start/Authenticate.snippet.read-user-metadata.swift
32+
:language: swift
33+
34+
- id: typescript
35+
content: |
36+
37+
.. literalinclude:: /examples/generated/node/authenticate.snippet.user-metadata.js
38+
:language: js

source/includes/update-user-metadata.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

source/sdk/users/user-metadata.txt

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,125 @@
44
User Metadata
55
=============
66

7+
.. meta::
8+
:description: Use Atlas Device SDK to read user metadata, such as email or birthday, from configured authentication providers.
9+
:keywords: Realm, Flutter SDK, Kotlin SDK, .NET SDK, Node.js SDK, Swift SDK, code example
10+
11+
.. facet::
12+
:name: genre
13+
:values: reference
14+
15+
.. facet::
16+
:name: programming_language
17+
:values: csharp, dart, javascript/typescript, kotlin, swift
18+
719
.. contents:: On this page
820
:local:
921
:backlinks: none
1022
:depth: 2
1123
:class: singlecol
1224

13-
Placeholder page for user metadata content.
25+
.. tabs-selector:: drivers
26+
27+
This page describes how to manage user metadata for an authorized App
28+
Services App user using Atlas Device SDK. For more information,
29+
refer to :ref:`auth-provider-metadata` in the App Services documentation.
30+
31+
Atlas App Services can read **user metadata** from authentication providers,
32+
such as Google or Facebook. Then, App Services exposes each user's metadata in
33+
a field of their ``User`` object. For example, you might want to access a
34+
user's name, email, birthday, or gender. This is read-only data that comes
35+
from the third-party authentication provider.
36+
37+
This is distinct from maintaining your own, editable custom user data. If
38+
you'd like to define your own user data fields, or have the ability to directly
39+
update user data, use :ref:`sdks-custom-user-data`.
40+
41+
.. important:: Configure Metadata in Atlas
42+
43+
Before you can work with metadata provided by the authentication provider,
44+
you must :ref:`configure metadata for the authentication provider
45+
<configure-user-metadata-on-the-backend>`.
46+
47+
.. _sdks-read-user-metadata:
48+
49+
Read User Metadata
50+
------------------
51+
52+
.. tabs-drivers::
53+
54+
.. tab::
55+
:tabid: csharp
56+
57+
.. include:: /includes/api-details/csharp/users/user-metadata-read-user-metadata-description.rst
58+
59+
.. tab::
60+
:tabid: dart
61+
62+
.. include:: /includes/api-details/dart/users/user-metadata-read-user-metadata-description.rst
63+
64+
.. tab::
65+
:tabid: javascript
66+
67+
.. include:: /includes/api-details/javascript/users/user-metadata-read-user-metadata-js-ts-description.rst
68+
69+
.. tab::
70+
:tabid: kotlin
71+
72+
.. include:: /includes/api-details/kotlin/users/user-metadata-read-user-metadata-description.rst
73+
74+
.. tab::
75+
:tabid: swift
76+
77+
.. include:: /includes/api-details/swift/users/user-metadata-read-user-metadata-description.rst
78+
79+
.. tab::
80+
:tabid: typescript
81+
82+
.. include:: /includes/api-details/javascript/users/user-metadata-read-user-metadata-js-ts-description.rst
83+
84+
.. include:: /includes/sdk-examples/users/user-metadata-read-user-metadata.rst
85+
86+
User metadata options vary depending on which provider you're using and
87+
:ref:`which metadata fields you enable <configure-user-metadata-on-the-backend>`.
88+
89+
.. include:: /includes/stale-user-metadata.rst
90+
91+
.. _sdks-serializable-user-metadata:
92+
93+
Serializable User Metadata
94+
~~~~~~~~~~~~~~~~~~~~~~~~~~
95+
96+
Some of the SDK languages provide serializers for user metadata.
97+
98+
.. tabs-drivers::
99+
100+
.. tab::
101+
:tabid: csharp
102+
103+
.. include:: /includes/api-details/generic/users/user-metadata-serializable-user-metadata-not-supported.rst
104+
105+
.. tab::
106+
:tabid: dart
107+
108+
.. include:: /includes/api-details/generic/users/user-metadata-serializable-user-metadata-not-supported.rst
109+
110+
.. tab::
111+
:tabid: javascript
112+
113+
.. include:: /includes/api-details/generic/users/user-metadata-serializable-user-metadata-not-supported.rst
114+
115+
.. tab::
116+
:tabid: kotlin
117+
118+
.. include:: /includes/api-details/kotlin/users/user-metadata-serializable-user-metadata-description.rst
119+
120+
.. tab::
121+
:tabid: swift
122+
123+
.. include:: /includes/api-details/generic/users/user-metadata-serializable-user-metadata-not-supported.rst
124+
125+
.. tab::
126+
:tabid: typescript
127+
128+
.. include:: /includes/api-details/generic/users/user-metadata-serializable-user-metadata-not-supported.rst

0 commit comments

Comments
 (0)