Authentication
Authentication is fully optional - unless you need to perform an action that specifically asks for authorization.
While most API actions can be performed without any form of authentication, certain actions that involve modification
or access to sensitive information require you to authorize yourself. These methods and publications are normally
prefixed with admin.
and require administrative permissions for the associated shop.
Fetching your login token
Head over to atshop.io and login. Once logged in, open up your browser's developer console and run the following line of code to fetch your current login token.
Meteor._localStorage.getItem('Meteor.loginToken');
You'll see a string of text show up when you run the line - this is your login token.
If you need to invalidate the token, simply log out or run the following in your developer console:
Meteor.logout();
Logging in
Pull in the ddp-login
plugin and execute the
loginWithToken()
method when connected to DDP.
const Login = require('ddp-login');
const loginToken = 'login-token-from-above';
// Your DDP connect call from the introduction:
DDPClient.connect((err, reconnected) => {
if (err) {
throw err;
}
Login.loginWithToken(DDPClient, loginToken, (err, user) => {
// You are now logged in.
})
});