Authorization Process
Authorization Process Overview
The Authorization Process is an important step throughout your Beefree SDK installation process. This steps validates your Beefree SDK credentials and provides you with a token. Take the steps outlined in this document to ensure you accurately complete the authorization process.
Beefree SDK Client-side Configuration
Beefree SDK requires the host application to pass a container parameter in the client-side configuration. This is the only required parameters for the configuration.
The following code sample shows an example of this parameter in the client-side configuration.
Beefree SDK Server-side Login
To initialize your instance of the Beefree SDK builder, call the /loginV2
endpoint shown in the sample code below with your Client ID, Client Secret, and UID. The Client ID and Secret are available on the application details page of the Beefree SDK developer portal. UID represents your user as described in How the UID parameter works.
Important: Do not put your Beefree SDK credentials in client-side code.
The Beefree SDK system uses OAuth2 as the authorization framework.
Example
Reference How the UID parameter works to learn more about UID.
The following code sample displays an example JSON response.
The Beefree SDK authorization service will return a temporary access token if the authentication is successful. The client application can use the full response that contains the token to start or refresh a Beefree SDK session.
The token you receive from the authorization server should be passed to the BeePlugin.create(...) as it is. We strongly suggest not altering it in any way. Also, don’t rely on the token response's content or structure. If you do, any change to the schema could make your integration stop working.
The token expires after 5 minutes for security reasons. Beefree SDK will refresh an expired token automatically for 12 hours without re-authenticating the application. Beefree SDK will trigger the onError
callback when the token can't be refreshed automatically.
Note: When a refreshable token expires, Beefree SDK receives a 401 error and attempts to refresh it automatically. 401 errors are expected and part of the process.
The following code sample displays an example of how to call the Beefree SDK endpoint, obtain a token, and then start it.
Ensure to call the authorization endpoint server-side to protect your credentials.
Once you obtain the token, the configuration parameters object is passed to Beefree SDK to set up your customization options, for example setting the editor’s language to “Spanish”.
Then, you can use Beefree SDK methods to start your instance and display the editor on your page.
Beefree SDK will keep this session alive for 12 hours from the login. After 12 hours, you have to manage the token expiration, as follows:
Obtain a new token via the new authorization endpoint.
Inject the token obtained from step one via the
updateToken
method. Reference examples of this in the following section.
The following code example shows how to inject the token in the current Beefree SDK instance:
The following code example displays how to get the current JSON from the expiration error:
Error Management
When you set up an onError
callback you will get the error
object as a parameter.
From that object, you can grab the code
property and use it as explained in the table below.
Handling error management
The following code samples display how to handle the 5101 and 5102 errors.
Error management error 5101
Error Responses
Example error response for unsupported media type Only Content-Type: application/json
is allowed.
Example error response for an invalid UID. Look at the properties of UID parameter.
Example error response for invalid credentials. Obtain your credentials using the authorization process.
Example error response for disabled apps. Contact support if you encounter this error.
Last updated