Go to file
Maxime Renou 7e13ddcf67 update guzzle 2020-12-09 14:00:25 +01:00
config Routes 2020-05-12 13:00:14 +02:00
resources translations 2020-05-12 18:54:56 +02:00
src Fix class lookup 2020-05-13 13:24:18 +02:00
.gitignore First commit 2020-05-11 16:26:34 +02:00
README.md README 2020-05-13 13:41:09 +02:00
composer.json update guzzle 2020-12-09 14:00:25 +01:00
composer.lock update guzzle 2020-12-09 14:00:25 +01:00



The Bluesquare Connect package allows you to use its OAuth server and sync its resources.


Update your composer.json:

"require": {
    "bluesquare/laravel-connect": "dev-master"
"repositories": [
        "type": "vcs",
        "url": "https://git.bluesquare.io/bluesquare/laravel-connect"

Install the package:

composer update bluesquare/laravel-connect

Finally, update your .env with your client's credentials:


Sign in with Bluesquare Connect

Follow there instructions to add Bluesquare Connect's authentication to your app.

Update your routes/web.php:


Add the "Sign in with Bluesquare Connect" button in your blade login page:


Make sure that the password column of users table is nullable.

Keep user tokens (optional)

First, make sure that your model implements HasConnectTokens trait.

Then, add the following columns to your table:


Database syncing

Follow these instructions to sync your database with Bluesquare Connect.

In your AppServiceProvider, specify in the boot() function which entities you want to sync:


Your models must use HasConnectSync trait. This trait allows you to customize the syncing behavior.

You also need to add this column to your synced tables:


You can customize this column name and the syncing behavior in your model. Take a look at HasConnectSync.

Finally, use this command to sync everything:

php artisan connect:sync

Live updates (optional)

First, configure a webhook on Bluesquare Connect :


Then, update your routes/api.php:


Advanced usage

OAuth (sign in)


Redirect to Bluesquare Connect authorization page:

public function authorize(Connect $connect)
    return $connect->redirect($optional_custom_state);

Authorization callback

Auto: check state, login and redirect

public function callback(Request $request, Connect $connect)
    return $connect->loginFromCallback($request, $optional_redirect_to);

Manual: check state

public function callback(Request $request, Connect $connect)
    $valid = $connect->checkState($request);
    // ...

Tokens management

// Retrieve tokens from an authorization code
$connect_data = $connect->getAccessTokenFromAuthorizationCode($code);

// Retrieve tokens from a refresh token
$connect_data = $connect->getAccessTokenFromRefreshToken($connect_data['refresh_token']);

// With HasConnectTokens trait: get your local user tokens

User data

// Retrieve user data from an access token
$user_data = $connect->getUserData($connect_data['access_token']);

// Example: find the corresponding user in your database
$user = User::where('email', $user_data['email'])->first();

OAuth (client)

Token management

// Get an access token

// Delete the current access token from cache

API resources

// Fetch all users

// Fetch an user
$connect->get('User', 1);


// Sync everything
$optional_resource_types = ['User', ...];

// Sync a specific resource
$connect->sync('User', 1);


// Handle a webhook request


Publish our config file (config/bconnect.php) to customize the package configuration:

php artisan vendor:publish