Search code examples
realmrealm-mobile-platform

Unknown provider returned from registerWithProvider


I am trying to create a custom auth provider called "cgpsauth" and I am getting "Unknown provider" when I call:

  var ru = Realm.Sync.User.registerWithProvider(
        "http://localhost:9080",
        "cgpsauth",
        accessToken,
        (error, user) => {...

Here is my provider which I know is being loaded because if I make a syntax error in this file I get an error when I launch the ROS:

module.exports = function(deps) {
  return class CgpsAuthProvider extends deps.BaseAuthProvider {

    static get name() {
      return 'custom/cgpsauth';
    }

    constructor(name, options, requestPromise) {
      super(name, options, requestPromise);
    }

    verifyIdentifier(req) {
      const token = req.body.data;
      return 30;
    }
  }
};

configuration.yml

 providers:
     custom/cgpsauth:
      implementation: cgpsauth.js

Solution

  • You have to prefix the provider name when authenticating from the client SDK with custom/:

    var ru = Realm.Sync.User.registerWithProvider(
        "http://localhost:9080",
        "custom/cgpsauth",
        accessToken,
        (error, user) => {...