Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

box-chrome-sdk

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

box-chrome-sdk

A Chrome App SDK for the Box V2 API

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
2
Weekly downloads
 
Created
Source

Chrome-App-SDK

Project Status Travis build status NPM info

Box V2 API SDK for Chrome apps and extensions written in AngularJS. With some effort, it can be used from node.js as well.

Installing

####bower

bower install box-chrome-sdk

####npm

npm install box-chrome-sdk

Quick Start

Setup

Make sure the following permissions are specified in your app's manifest:
permissions: [
    "downloads",
    "identity",
    "storage",
    "https://*.box.com/*",
    "https://*.boxcdn.com/*",
    "https://*.boxcdn.net/*",
    "https://*.boxcloud.com/*"
]
Include SDK and requirements javascript
<script src="box-chrome-sdk.bower_components.min.js"></script>
<script src="box-chrome-sdk.min.js"></script>
Configure the SDK with your Box app's client ID and secret
angular.module('box.conf')
    .constant('clientSecret', 'uII-----------------------------')
    .constant('clientId', 'i3p-----------------------------');

####Add a dependency to box.sdk to your angular module####

angular.module('myModule', ['box.sdk']);
Require boxSdk as a dependency in your angular services or directives
module.directive('myDirective', ['boxSdk', function(boxSdk) {

}]);

Making API Calls

Most functions in the SDK return Rx Observables. Mastery of reactive programming, however, is not required to use these objects.

To get at an API result, simply subscribe to the observable and read the result inside the callback.

Get a folder object
boxSdk.getFolder(0).subscribe(function(folder) {
    console.log(folder.name);
});

// -> All Files
boxSdk.search('query text')
    .subscribe(function(result) {
        console.log(result.type + ' -> ' + result.name);
    });

// -> Folder -> Query 1
// -> File -> Results Query

Device Pinning

Some Box enterprises enforce device pinning, and require that auth requests are accompanied by a device ID. Chrome doesn't support a device specific identifier, and that is by design.

However, it should be possible to supply a device ID, either from an application/extension setting supplied by a user, or by Chrome managed storage. Passing it with auth requests is as simple as:

var http = angular.module('box.http'),
    deviceId = getDeviceIdSomehow();

http.factory('boxDeviceIdInterceptor',['$q', 'authUrl', function($q, authUrl){
    return {
        request: function(config) {
            if (config.url.indexOf(authUrl) === 0) {
                config.data.append('box_device_id', deviceId);
            }
            return config;
        }
    };
}]);

http.config(['$httpProvider',function($httpProvider) {
    $httpProvider.interceptors.push('boxDeviceIdInterceptor');
}]);

Docs and examples

Search Box from OmniBox Example

Example extension showing how to use the SDK in an extension's background page.

Upload to Box Example

Example extension showing how to use the SDK in a content script.

Box Chrome App Example

Example packaged app showing how to use the SDK in a packaged app.

Node.js Example

Example login script showing how to use the SDK in a node.js script.

Notifications Example

Example events script showing how to use the SDK to monitor events.

Documentation

Docs

Building the SDK

Building the SDK requires Grunt. *If you are new to Grunt, you will find a lot of answers to your questions in their getting started guide.

From the same directory as Gruntfile.js, type

npm install
bower install
grunt

Running the tests

grunt test

Contributing

See CONTRIBUTING.

Support

Need to contact us directly? Email oss@box.com and be sure to include the name of this project in the subject.

Copyright 2014 Box, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

FAQs

Package last updated on 11 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc