Taken from http://docs.meteor.com/#/full/accountsclient
Note that AccountsClient is currently available only on the client, due to its use of browser APIs such as window.localStorage. In principle, though, it might make sense to establish a client connection from one server to another remote accounts server. Please let us know if you find yourself needing this server-to-server functionality.
So first things first, you will have to call your Alpha method from client code running in Bravo.
And to make sure that the Bravo client is logged in to the Alpha server, you can use the new AccountsClient to get a reference to a client and then use loginWithToken
on it to use the already existing token in the browser localstorage to initiate authentication.
If you want to login from your server, though, I guess you can use something like this.
I also have a few apps that are split up. To be honest, I evaluated and found this whole remote-DDP-connection-based approach very cumbersome.
Instead I place all my shared code into shared packages and use them natively, relying on mongodb and the oplog to carry over the inter-app and inter-instance communication for me.
I believe a remote DDP connection has its value for smaller integrations between two apps that don’t necessarily share their databases, or those that are based on microservice architectures and some of those services do not connect to a mongodb instance.
Either way, server to server authentication over DDP is a problem and DDP authentication from a client to a remote server is still not a very straightforward thing to achieve once you begin having non-standard or non-trivial authentication requirements.
What I would have loved as an enhancement to the accounts package is to have a global configuration option to send over all authentication request to a remote server and Meteor.loginWith… methods using that config.
In fact, an overall “Send down hot code pushes from the local server but point the client app to a remote server for anything else” configuration would be extremely helpful in separating large apps or creating multiple clients to a server.