Introducing the Box SDK for Salesforce

Box supports a growing community of developers, including many Salesforce developers building and deploying apps on the Salesforce App Cloud. To help make it ridiculously easy for Salesforce developers to use our APIs with their App Cloud apps, we are excited to announce the release of our Box SDK for Salesforce. You can check out the SDK on Github
 
Written in Apex, the Box SDK for Salesforce enables developers building on the Salesforce App Cloud to easily leverage Box content and collaboration features within their apps via the Box Platform Content API. The SDK supports Salesforce developers using our APIs to build custom apps for Box Users, as well as custom apps built on Box Platform for App Users.  It will also complement Box's existing Box for Salesforce integration, which allows you to tie Box's rich embed functionality that is delivered by the integration into your Salesforce processes and customizations. You can learn more about the Box for Salesforce integration in our AppExchange listing.
 
The SDK makes it incredibly simple to integrate content into App Cloud applications. For example, with only 5 lines of code you generate a file preview URL displayed on the page in the demo:

 

 public static String getFilePreviewLink(String fileId) {
        BoxApiConnection api = new BoxApiConnection(clientId, clientSecret, accessToken, refreshToken);
        BoxFile file = new BoxFile(api, fileId);
        String previewLink = file.getPreviewLink();
        return previewLink;
    }

Getting Started with the Box SDK for Salesforce

The SDK can be deployed directly to Salesforce Sandbox or Developer Orgs using the "Deploy to Sandbox" button on Github, or you can clone the source locally and deploy using the tool of your choice. 
 
Next, you'll need to authenticate and connect to the Box Platform Content API. 
 
If you are building apps for Box Users (and wish to require end users to have a Box account), you'll use OAuth for authentication. The SDK makes it easier by providing classes that handle obtaining tokens and automatically refreshing them. You can use developer tokens, normal authentication via the OAuth authentication endpoint, or you can manually authenticate for scenarios where you want to grant authorization once and store access and refresh tokens yourself. You can see a tutorial for using OAuth2.0 with Box here.
 
If you are building apps on Box Platform and using App Users, you'll need to use the BoxPlatformApiConnection class. This class allows your application to authenticate directly to Box using a JSON Web Token (JWT) grant and RSA keypair to obtain enterprise and user access tokens. Developers that wish to build on Box Platform can follow these instructions for using App Auth and App Users.
 
Once authenticated, you can make API requests to any point found in our documentation. 
 
We can't wait to see what apps you build using the Box SDK for Salesforce. As always, we welcome your feedback. You can reach us on Twitter at @BoxPlatform or email us.