Search code examples
phplaravelazurelaravel-socialite

How to add service entry for azure in Laravel


I want to add microsoft azure as an authentication method. I have followed laravel's and socialites documentation to add other methods than provided by laravel.

I have followed all the steps but I keep getting the error:

"SocialiteProviders \ Manager \ Exception \ MissingConfigException
There is no services entry for azure"

app.php:

'providers' => [
    /*
     * Laravel Framework Service Providers...
     */
    // Some more providers

    \SocialiteProviders\Manager\ServiceProvider::class,

],

'aliases' => [
    'Socialite' => Laravel\Socialite\Facades\Socialite::class,

],

EventServiceProvider.php:

    protected $listen = [
    Registered::class => [
        SendEmailVerificationNotification::class,
    ],
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        'SocialiteProviders\\Azure\\AzureExtendSocialite@handle',
    ],

];

services.php:

'azure' => [
    'client_id' => 'MY_ID',
    'client_secret' => 'MY_SECRET',
    'redirect' => 'http://localhost:8000/login/azure/callback',
],

Login Controller:

public function redirectToProvider()
{
    return Socialite::with('azure')->redirect();
}

/**
 * Obtain the user information from GitHub.
 *
 * @return \Illuminate\Http\Response
 */
public function handleProviderCallback()
{
    $user = Socialite::with('azure')->user();

    // $user->token;
}

I can not find anything about this problem on the internet. It seems like it's not reading the "azure" entry in services.php, but I have no idea how to fix it.

EDIT: Yes I have installed everything with composer.


Solution

  • So far I can see, is this an issue with your config caching. Here for you have to run php artisan config:clear, this will remove the caching of the config.