|
6 | 6 |
|
7 | 7 | MongoDB Charts allows you to create visualizations of your MongoDB data using a simple web interface. You can view the visualizations within the Charts UI, or you can use the Embedding feature to render the charts in an external web application.
|
8 | 8 |
|
9 |
| -Charts can be embedded either using a simple IFRAME snippet, or by using the Charts Embedding SDK from your JavaScript code. When using the SDK, embedded charts can be either unauthenticated (meaning anyone who has the embed code can view the chart), or authenticated (whereby the user can only view the chart if they have an active authentication session linked to a Charts authentication provider). |
| 9 | +Charts can be embedded either using a simple IFRAME snippet, or by using the Charts Embedding SDK from your JavaScript code. When using the SDK, embedded charts can be either unauthenticated (meaning anyone who has access to the page where the chart is embedded can view the chart), or authenticated (whereby the user can only view the chart if they have an active authentication session linked to a Charts authentication provider). |
10 | 10 |
|
11 | 11 | This sample shows how to use the JavaScript Embedding SDK to render **authenticated** embedded charts, specifically via configuring **Google** as an authentication provider. The sample app is already set up to authenticate with a Google Client ID hosted by the Charts Development team.
|
12 | 12 |
|
@@ -39,30 +39,48 @@ This sample is pre-configured with a MongoDB-owned test Client ID. To use Google
|
39 | 39 |
|
40 | 40 | Steps on how to configure a Project with Google and attain a Google Client ID can be found [here](https://developers.google.com/identity/sign-in/web/sign-in). You'll need to set the Origin and Redirect URIs to whatever you use in your application. In our sample, that is http://localhost:3000.
|
41 | 41 |
|
42 |
| -### Preparing your Chart for Embedding |
| 42 | +## Preparing your Chart for Embedding |
43 | 43 |
|
44 | 44 | This sample is preconfigured to render a specific chart. You can run the sample as-is, or you can modify it to render your own chart by completing the following steps:
|
45 | 45 |
|
| 46 | +### Create chart to embed |
| 47 | + |
46 | 48 | 1. Log onto MongoDB Charts
|
47 | 49 |
|
48 | 50 | 2. If you haven't done so already, create a chart you would like to embed on any dashboard.
|
49 | 51 |
|
50 |
| -3. Go to the Data Sources tab on the left navigation column. Find the data source that you are using on the chart, and choose External Sharing Options from the ... menu. Make sure that embedding is enabled for this data source and select '**Authenticated Embedding Only**' |
| 52 | +### Enable data source for authenticated access |
51 | 53 |
|
52 |
| -4. Go to the Admin Settings tab on the left navigation column. Under 'Embedding Authentication Providers', click 'Add New Provider'. |
| 54 | +3. Go to the Data Sources tab found on the side panel. |
53 | 55 |
|
54 |
| - - Name your Provider e.g `Google` |
55 |
| - - Select the Google Provider. |
56 |
| - - Enter your Google Client ID |
57 |
| - - This should be the entire string `<encodedData>.apps.googleusercontent.com` |
| 56 | +4. Find the data source that you want to use on the chart by selecting the deployment, database and collection. Once found, click on the Manage button in the Data access section to access the Data source management page. |
| 57 | + |
| 58 | +5. Make sure the "External users can view data in this data source" option is toggled on and "Allow authenticated data access" has been selected. |
| 59 | + |
| 60 | +### Enable chart for embedded access |
| 61 | + |
| 62 | +6. Go to the Dashboards tab on the side panel, and select the dashboard that contains the chart you wish to embed. |
| 63 | + |
| 64 | +7. Find the chart you want to embed, click the **...** menu and select **Embed chart** |
58 | 65 |
|
59 |
| -5. Go to the Dashboards tab on the left navigation column, and select the dashboard that contains the chart you wish to embed. |
| 66 | +8. Ensure the **Authenticated** tab is selected and turn on '**Enable authenticated access**' |
60 | 67 |
|
61 |
| -6. Find the chart you want to embed, click the **...** menu and select **Embed Chart** |
| 68 | +9. Note the **Chart ID** and the **Base URL**, as you will need them for running the demo. |
62 | 69 |
|
63 |
| -7. Ensure the Unauthenticated tab is selected and turn on '**Enable Authenticated access**' |
| 70 | +### Create authentication provider |
64 | 71 |
|
65 |
| -8. Note the Chart ID and the Chart Base URL, as you will need them for running the demo. |
| 72 | +10. Go to the Embedding tab on the side panel. |
| 73 | + |
| 74 | +11. Ensure the "Authentication Settings" tab is selected and press the "Add" button in the Authentication providers section. |
| 75 | + |
| 76 | +12. Go to the Admin Settings tab on the left navigation column. Under 'Embedding Authentication Providers', click 'Add New Provider'. |
| 77 | + |
| 78 | +13. Fill in the details like so: |
| 79 | + |
| 80 | + - Name: `Google` _Note, this is only for your convenience and can be named anything you want here_ |
| 81 | + - Provider: `Google` |
| 82 | + - Google Client ID: _See above for |
| 83 | + - This should be the entire string `<encodedData>.apps.googleusercontent.com` |
66 | 84 |
|
67 | 85 | ## Running this Sample with your data
|
68 | 86 |
|
|
0 commit comments