Laravel Box

Install

Application Register

To use Box API an application needs creating at https://app.box.com/developers/console/newapp

Select the type of application. Select custom if you need to access the API abilities. Select the Oauth2 app type after selecting custom.

Install

Via Composer

composer require dcblogdev/laravel-box

Config

You can publish the config file with:

php artisan vendor:publish --provider="Dcblogdev\Box\BoxServiceProvider" --tag="config"

When published, the config/box.php config file contains:

return [
    'clientId'       => env('BOX_CLIENT_ID'),
    'clientSecret'   => env('BOX_SECRET_ID'),
    'redirectUri'    => env('BOX_REDIRECT_URI'),
    'boxLandingUri'  => env('BOX_LANDING_URI'),
    'urlAuthorize'   => 'https://account.box.com/api/oauth2/authorize',
    'urlAccessToken' => 'https://www.box.com/api/oauth2/token',
];

Migration

You can publish the migration with:

php artisan vendor:publish --provider="Dcblogdev\Box\BoxServiceProvider" --tag="migrations"

After the migration has been published you can create the tokens tables by running the migration:

php artisan migrate

.ENV Configuration

You should add the env variables to your .env file, this allows you to use a different box application on different servers, each box application requires a unique callback URL.

The following are required when using OAuth 2.0 credentials:

The BOX_REDIRECT_URI is where Box should redirect to for authentication with Box, upon successful authentication the BOX_LANDING_URI is used to direct a user to the desired page. > Note BOX_REDIRECT_URI needs to be the full URI ie https://domain.com/box/

BOX_CLIENT_ID=
BOX_SECRET_ID=
BOX_REDIRECT_URI=https://domain.com/box/oauth
BOX_LANDING_URI=https://domain.com/box

Copyright © 2006 - 2024 DC Blog - All rights reserved.