2016-06-20 6 views
0

私は間違いなくこの問題を回避することはできません。私はLaravel 5.2のチュートリアルに従っています。Laravel SocialiteとOffice365:Manager.phpでInvalidArgumentExceptionが発生しました90:ドライバー[Microsoft]がサポートされていません

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

そしてタイトルに上記のエラーを取得。私のルートは次のようになります。

<?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() 
     { 

     } 
} 

そしてservices.php次のようになります:私は私は考えている

<?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'), 
    ], 

]; 

そして、それ以外の

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

Route::get('/redirect', '[email protected]'); 
Route::get('/callback', '[email protected]'); 

コントローラは、このようになります間違っている可能性があります。私の方法で光を!

+0

あなたはMicrosoftとしようとしています。しかし、このエラーは「Driver [Microsoft]はサポートされていません」と述べています。また、Socialiteのドキュメントごとに、Socialiteは現在、Facebook、Twitter、LinkedIn、Google、GitHub、Bitbucketによる認証をサポートしています。 –

+0

それでは、Microsoftをサポートできるようにカスタムドライバを作成する方法は? –

答えて

2

Microsoft GraphプロバイダをSocialite Providersパッケージから使用することをおすすめします。あなたのcomposer.jsonファイルを経由して、マイクロソフト・グラフ・プロバイダーで

プル:

"require": { 
    ... 

    "laravel/socialite": "^2.0", 
    "socialiteproviders/microsoft-graph": "dev-master" 
}, 

実行composer update

次に、config/services.phpへの接続の資格情報を追加します。

... 

'graph' => [ 
    'client_id'  => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 
    'client_secret' => 'xxxxxxxxxxxxxxxxxxxxxxx', 
    'redirect'  => 'https://my-app.dev', 
], 

を*注意:公共のレポへconfig/services.phpをコミットする場合は、あなたの.envファイルにこれらの値を抽出し、env helper method経由でそれらを参照。

'aliases' => [ 
    ... 

    'Socialize' => 'Laravel\Socialite\Facades\Socialite', 

], 

app/Providers/EventServiceProvider.phpにイベントリスナーを登録します:

'providers' => [ 
    ... 

    /* 
    * Package Service Providers... 
    */ 
    Laravel\Socialite\SocialiteServiceProvider::class, 

    // This is a dependency of the socialiteproviders/microsoft-graph provider, and will be installed with the provider via it's composer.json file 
    SocialiteProviders\Manager\ServiceProvider::class, 

は(もconfig/app.phpで)Socializeファサードを登録:config/app.php

providersアレイにSocialiteProviders/Generatorsサービスプロバイダを追加します

protected $listen = [ 
    ... 

    'SocialiteProviders\Manager\SocialiteWasCalled' => [ 
     'SocialiteProviders\Graph\[email protected]' 
    ], 
]; 

リクエストを処理するために、あなたのコントローラを作成します。

<?php 

namespace App\Http\Controllers\Auth; 

use Illuminate\Http\Request; 
use Socialize; 

class AuthController extends \App\Http\Controllers\Controller 
{ 

    /** 
    * Redirect the user to the Graph authentication page. 
    * 
    * @return Response 
    */ 
    public function redirectToProvider() 
    { 
     return Socialize::with('graph')->redirect(); 

    } 

    /** 
    * Obtain the user information from graph. 
    * 
    * @return Response 
    */ 
    public function handleProviderCallback(Request $request) 
    { 
     $user = Socialize::with('graph')->user(); 

     // $user->token; 
    } 
} 

は最後にroutes/web.phpであなたのルートを追加します。

<?php 

Route::get('auth/graph', 'Auth\[email protected]'); 
Route::get('auth/graph/callback','Auth\[email protected]'); 
関連する問題