realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.81k stars 577 forks source link

Align Realm JS and Realm Web API Key credentials #3050

Open kraenhansen opened 4 years ago

kraenhansen commented 4 years ago

We've discussed merging the concept of server and a user API keys in the SDKs and the current implementation publishes two different methods for server and user API keys.

Current situation:

  1. The typescript declarations declare two static methods serverApiKey and userApiKey https://github.com/realm/realm-js/blob/v10/types/app.d.ts#L152.
  2. The mongodb.com docs mentions a single apiKey https://docs.mongodb.com/realm/node/authenticate/#api-key.
  3. Realm Web implements both serverApiKey, userApiKey and apiKey https://github.com/realm/realm-js/blob/v10/packages/realm-web/src/Credentials.ts#L59-L91.
  4. Realm JS implements both serverApiKey and userApiKey https://github.com/realm/realm-js/blob/v10/src/js_app_credentials.hpp#L62-L63.
johnsaigle commented 4 years ago

The documentation also points to a single apiKey function which causes an error in Realm (node sdk).

https://docs.mongodb.com/realm/node/authenticate/#api-key

Using Realm.Credentials.serverApiKey() instead of Realm.Credentials.apiKey() works.