Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

scorphgar91's avatar

InvalidArgumentException in Manager.php line 90: Driver [microsoft] not supported.

Hey again! So I definitely can't wrap my head around this one. I'm following a Laravel 5.2 tutorial here.

http://blog.damirmiladinov.com/laravel/laravel-5.2-socialite-facebook-login.html#.V2gUIrgrJPY

And getting the error listed above in the title. My routes look like this:

Route::get('/', function () {
    if(Auth::check()) return view('auth/register');
    return view('auth/login');
});

Route::get('/redirect', 'MailAuthController@redirect');
Route::get('/callback', 'MailAuthController@callback');

Controller looks like this:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Socialite;

class MailAuthController extends Controller
{
    //
    public function redirect()
      {
          return \Socialite::with('microsoft')->redirect();
      }

    public function callback()
      {
          // when microsoft calls with token
      }

    public function user()
      {

      }
}

And services.php looks like this:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Third Party Services
    |--------------------------------------------------------------------------
    |
    | This file is for storing the credentials for third party services such
    | as Stripe, Mailgun, Mandrill, and others. This file provides a sane
    | default location for this type of information, allowing packages
    | to have a conventional place to find your various credentials.
    |
    */

    'mailgun' => [
        'domain' => env('MAILGUN_DOMAIN'),
        'secret' => env('MAILGUN_SECRET'),
    ],

    'mandrill' => [
        'secret' => env('MANDRILL_SECRET'),
    ],

    'ses' => [
        'key' => env('SES_KEY'),
        'secret' => env('SES_SECRET'),
        'region' => 'us-east-1',
    ],

    'sparkpost' => [
        'secret' => env('SPARKPOST_SECRET'),
    ],

    'stripe' => [
        'model' => App\User::class,
        'key' => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET'),
    ],

    'microsoft' => [
        'client_id' => env('MICROSOFT_CLIENT_ID'),
        'client_secret' => env('MICROSOFT_CLIENT_SECRET'),
        'redirect' => env('http://localhost:8000/callback'),
    ],

];

And other than that I have no idea where I might be going wrong. Light my way!

0 likes
2 replies
martinbean's avatar

@scorphgar91 The error message tells you what the problem is:

Driver [microsoft] not supported.

You’ve specified a “microsoft” driver, but it’s not supported by Socialite out of the box.

You’ll need to either create a driver yourself, or use a pre-built one. Have a look on https://github.com/SocialiteProviders/

scorphgar91's avatar

Thank you! So given I have the custom provider class below:

<?php    namespace App\Login\Providers;

use Laravel\Socialite\Two\AbstractProvider;
use Laravel\Socialite\Two\ProviderInterface;
use Laravel\Socialite\Two\User;

class MicrosoftServiceProvider extends AbstractProvider implements ProviderInterface
{

    protected function getAuthUrl($state)
    {
        return $this->buildAuthUrlFromBase('https://login.windows.net/common/oauth2/authorize', $state);
    }

    protected function getTokenUrl()
    {
        return 'https://login.windows.net/common/oauth2/token';
    }

    public function getAccessToken($code)
    {
        $response = $this->getHttpClient()->post($this->getTokenUrl(), [
            'headers' =>
                [
                    'Content-type'=>'application/x-www-form-urlencoded',
                ],
            'form_params'    => $this->getTokenFields($code),
        ]);

        return $this->parseAccessToken($response->getBody());
    }

    protected function getTokenFields($code)
    {
        $base_args = parent::getTokenFields($code);
        $base_args = array_add($base_args, 'resource', 'https://graph.windows.net');
        $base_args = array_add($base_args, 'grant_type', 'authorization_code');

        return $base_args;
    }

    protected function getUserByToken($token)
    {
        $response = $this->getHttpClient()->get('https://graph.windows.net/me?api-version=1.5', [
            'headers' => [
            'Authorization' => 'Bearer ' . $token,
            'Content-type'=>'application/json',
        ],
        ]);

        return json_decode($response->getBody(), true);
    }

    protected function mapUserToObject(array $user)
    {
        return (new User)->setRaw($user)->map([
            'email'         => $user['mail'],
            'nickname'      => $user['mailNickname'],
            'name'          => $user['displayName'],
            'firstName'     => $user['givenName'],
            'lastName'      => $user['surname'],
            'externalId'    => $user['objectId'],
        ]);
    }

}

I then added this:

      App\Providers\MicrosoftServiceProvider::class,

To config\app.php. However, now I'm getting the following error.

FatalThrowableError in AbstractProvider.php line 94:
Type error: Argument 1 passed to Laravel\Socialite\Two\AbstractProvider::__construct() must be an instance of Illuminate\Http\Request, instance of Illuminate\Foundation\Application given, called in /home/vagrant/sites/portfolioPage/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
1 like

Please or to participate in this conversation.