Initializing the plugin

To initialize your instance of BEE editor, call the endpoint shown in the sample code below with your Client ID and Client Secret, which are available in the application details page of the BEE Plugin developer portal (if you don’t have an account, sign up).

The BEE Plugin system uses OAuth2 as the authorization framework.




POST /apiauth HTTP/1.1
Host: auth.getbee.io
Content-Type: application/json 
Accept: application/json
Content-Type: application/x-www-form-urlencoded
grant_type=password&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET


If the authentication is successful, the BEE Plugin authorization service will return a temporary access token to the client application. The token can then be used by the client application to start communicating with the BEE Plugin resource server.

The token has a duration of one minute after which it expires, for security reasons. An expired token can be refreshed for 30 minutes without re-authenticating the application.  Once the application has started communicating with the BEE Plugin resource server, the plugin will take care of refreshing the token automatically as long as someone is actively using the editor, and for 20 minutes during inactivity.

Here is an example of how to call the BEE Plugin endpoint, obtain a token and then start the plugin:




var req = new XMLHttpRequest();
req.onreadystatechange = function() {
	if (req.readyState === 4 && req.status === 200) {
		// Obtain token
    	var token = req.responseText;
    	// Call create method and pass token and beeConfig to obtain an instance of BEE Plugin
    	BeePlugin.create(token, beeConfig, function(beePluginInstance) {
			// Call start method of bee plugin instance
	    	beePluginInstance.start(template); // template is the json to be loaded in BEE
		});
	}
};
req.open(
	'POST', 	// Method
	'/token', 	// The server side endpoint that calls BEE REST auth endpoint
	false 		// sync request
);


You can consume this endpoint both clientside and serverside. Make sure that this endpoint is consumed over the HTTPS protocol if invoking it from a Web client.

When you do…

  1. The system will return a valid token (it will be refreshed automatically by the plugin).
  2. Configuration parameters are passed to BEE Plugin to set up the options you wish (e.g. setting the editor’s language to “Spanish”).
  3. You can use BEE plugin methods, start your instance and display the editor in your page.