gpt4 book ai didi

php - Laravel Socialite 和 Office365 : InvalidArgumentException in Manager. php 第 90 行:不支持驱动程序 [microsoft]

转载 作者:行者123 更新时间:2023-12-02 17:27:03 25 4
gpt4 key购买 nike

所以我绝对不能绕过这个。我在这里学习 Laravel 5.2 教程。

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

并得到上面标题中列出的错误。我的路线如下所示:

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 看起来像这样:

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

];

除此之外,我不知道我可能哪里出错了。照亮我的路!

最佳答案

我建议使用 Microsoft Graph提供者来自 Socialite Providers包。

通过您的 composer.json 文件引入 Microsoft-Graph 提供程序:

"require": {
...

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

运行 Composer 更新

接下来,将连接凭据添加到 config/services.php:

...

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

*注意:如果将 config/services.php 提交到公共(public)存储库,请将这些值提取到您的 .env 文件并通过 env helper method 引用它们;

config/app.php 中,将 SocialiteProviders/Generators 服务提供商添加到 providers 数组:

'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,

注册 Socialize 门面(也在 config/app.php 中):

'aliases' => [
...

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

],

app/Providers/EventServiceProvider.php 中注册一个事件监听器:

protected $listen = [
...

'SocialiteProviders\Manager\SocialiteWasCalled' => [
'SocialiteProviders\Graph\GraphExtendSocialite@handle'
],
];

创建你的 Controller 来处理请求:

<?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\AuthController@redirectToProvider');
Route::get('auth/graph/callback','Auth\AuthController@handleProviderCallback');

关于php - Laravel Socialite 和 Office365 : InvalidArgumentException in Manager. php 第 90 行:不支持驱动程序 [microsoft],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37929579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com