Middleware.php第69行的ClientException: 客户端错误:400
我已经完成以下步骤:
1. 运行命令 `composer require laravel/socialite` 和 `composer update`。 2. 在我的 `config>services.app` 中增加了以下内容:
'facebook' => [ 'client_id' => env('FB_CLIENT_ID'), 'client_secret' => env('FB_SECRET_ID'), 'redirect' => 'http://localhost.com:8888', ],
3. 在 `config>app.php` 中增加了 `Laravel\Socialite\SocialiteServiceProvider::class` 和 `'Socialite' => Laravel\Socialite\Facades\Socialite::class,`。 4. 成功设置路由。
``` Route::get('auth/facebook', 'Auth\AuthController@redirectToProvider'); Route::get('auth/facebook', 'Auth\AuthController@handleProviderCallback'); ```
Setup the link successfully in my blade file.
Login with Facebook
In my Controller>AuthController.php, I added:
use Laravel\Socialite\Facades\Socialite; ** Beside everything that AuthController has, inside the AuthController class, I added:** public function redirectToProvider() { return Socialite::driver('facebook') ->scopes(['scope1', 'scope2'])->redirect(); } /** * Obtain the user information from Facebook. * * @return Response */ public function handleProviderCallback() { $user = Socialite::driver('facebook')->user(); // $user->token; }
Also users table:
public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('username'); $table->string('name'); $table->string('email')->unique(); $table->string('password', 60); $table->string('avatar'); $table->string('provider'); $table->string('provider_id'); $table->rememberToken(); $table->timestamps(); }); }
编辑:
当我注释掉$user = Socialite::driver('facebook')->user();
这一部分时,我被重定向到localhost.com/auth/facebook
编辑2:
我的.env
文件:
'facebook' => [
FB_CLIENT_ID => '###',
FB_SECRET_ID => 'this-is-secret!',
],
auth/facebook/callback
,现在它正在重定向到 Facebook。但是,正如 @Francismori7 所说,在这里我收到一个错误:Facebook 错误 ->Invalid Scope: scope1
。我应该完全删除->scopes(['scope1', 'scope2'])->redirect();
部分吗? - sentyreturn Socialite :: driver('facebook')->redirect();
,现在它成功地重定向到FB,但现在我面临一个错误:Invalid App ID ->#MyAppid#
,而我在链接栏上有OAuth客户端...fb.com/dialog/oauth?client_id=>+ bla bla bla bla bla
- senty