padarom/battlenet-socialite OAuth2 Provider for Laravel Socialite



Socialite Provider

This library contains a OAuth 2 Provider for Laravels Socialite Authentication layer.


First of all, make sure you follow the installation instructions listed on laravel/socialite.

To get started with this provider, first add the library to the requirements listed in your composer.json file:

composer require padarom/battlenet-socialite

After installing the library, register its service provider in your config/app.php to your providers array:

'providers' => [
    // Other service providers...


Before using it, you will need to add your application credentials to your config/services.php file:

'battlenet' => [
    'client_id' => 'your-battlenet-app-id',
    'client_secret' => 'your-battlenet-app-secret',
    'redirect' => 'https://your-callback-url',
    'region' => 'eu',

A description on how to create a application can be found in the User and App Registration Guide.

Basic Usage

This example is derived from the previously mentioned laravel/socialite package, adjusted for this provider.


namespace App\Http\Controllers\Auth;

use Socialite;

class AuthController extends Controller
     * Redirect the user to the authentication page.
     * @return Response
    public function redirectToProvider()
        return Socialite::driver('')->redirect();

     * Obtain the user information from
     * @return Response
    public function handleProviderCallback()
        $user = Socialite::driver('')->user();

        // $user->token;

Then, route your requests to these controller methods:

Route::get('auth/github', 'Auth\AuthController@redirectToProvider');
Route::get('auth/github/callback', 'Auth\AuthController@handleProviderCallback');