mongodb-js / charts-embed-sdk

The easiest way to embed MongoDB Charts visualisations into your web app

Home Page:https://docs.mongodb.com/charts/master/embedding-charts-sdk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mongodb-stitch-browser-sdk deprecated

shash7976 opened this issue · comments

Hi,

Is your feature request related to a problem? Please describe.
As you might already know that mongodb-stitch-browser-sdk is deprecated and no longer maintained.

Could you suggest to me an alternative way of using MongoDB realm authentication for the charts-embed-SDK

I tried using realm-web and passed the authentication response to (getRealmUserToken function) charts-embed but it throws a typescript error.

TIA

Hello @shash7976, thank you for reporting this. We are aware of the deprecation of the mongodb-stitch-browser-sdk package and will provide a fix for the getRealmUserToken embedding option or an alternative solution for the realm authentication for embedded charts and dashboards.
We do have a ticket for this but it's not scheduled yet. Apologies for the inconvenience and will keep you updated on this.

commented

Is there any update and or workaround available for this issue? We've migrated to realm-web and are facing this issue now.

The fix for the util getRealmUserToken to work with the realm-web sdk is in progress and will be included in the next charts-embed-sdk version.

A workaround when using realm-web is to pass the Realm token directly to the ChartsEmbedSDK class without using the getRealmUserToken util. Something like:

import * as Realm from "realm-web";
import ChartsEmbedSDK from "@mongodb-js/charts-embed-dom";

const client = new Realm.App({
  id: <your Realm App ID>,
});

// on login
const credentials = Realm.Credentials.emailPassword(<email>, <pass>);
const user = await client.logIn(credentials);

const chartsSDK = new ChartsEmbedSDK({
    baseUrl: "<your Charts Base Url>", 
    getUserToken: () => user._accessToken,
  });

Hello @shash7976 and @jvpelt!

Just wanted to update y'all that v2.3.0 of the SDK has been released and this includes support for realm-web with our getRealUserToken method!

You can see a working example in this repo here.

I'll be closing this issue since we believe it's resolved now. Let us know if you run into anymore problems!