- Sign up for a free Box Developer account or log in to the Box Developer Console.
- Select "Create New App".
- Select "Custom App" and click "Next".
- Select "OAuth 2.0 with JWT (Server Authentication)" and click "Next".
- Name the application "Box Node Express Sample - YOUR NAME".
- Application names must be unique across Box.
- Click "Create App" and then "View Your App".
- Click "Generate a Public/Private Keypair".
- You may need to enter a 2-factor confirmation code.
- Save the JSON config file -- this config file also contains the private key generated for your application.
- Note: Box does not store the generated private key and this config file is the only copy of the private key. You can always delete this keypair from your application and generate a new keypair if you lose this config file.
- Be sure to add your configuration file to the
app
directory. - In the "CORS Allowed Origins" section, add
http://localhost:3000
.
- In a new tab, log in to your Box account with the admin account and go to the Admin Console.
- Applications that use Server Authentication must be authorized by the admin of the account.
- Signing up for a free Box Developer account gives you access to a Box Enterprise.
- Under the gear icon, go to Enterprise Settings (or Business Settings, depending on your account type).
- Navigate to the Apps tab.
- Under "Custom Applications", click "Authorize New App".
- Enter the "Client ID" value from your Box application in the "API Key" field.
- Your application is now authorized to access your Box account.
- Navigate to
box-node-express-skeleton-app
>app
>config
>default.js
. - Add your own Box Config to the
app
directory underbox-node-express-skeleton-app
>app
. - Add the environment variables from your Box application to the
default.js
file:- Note: If you name your config file
config.json
, there are no changes needed. - Under
module.exports.BoxSDKConfig
:
boxConfigFilePath: Path to your Box Config file generated when creating a new Box App. // For example, boxConfigFilePath: "config.json"
- Note: If you name your config file
For convenience, we've included a docker-compose.yml
file for running Redis and this application. Redis is used in caching tokens and improving performance.
Make sure you have Docker and Docker Compose installed and use the command docker-compose up
to start this application.
- Download Docker here:
- Docker Community Edition
If you need to bring the application down, run docker-compose down
.
The following port must be available on your machine:
3000
Once the server is running, navigate to http://localhost:3000.
Need to contact us directly? You can post to the Box Developer Forum.
Copyright 2017 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.