From e6d3e3f3fd77f1393440b8b2a060d4d991a56ffc Mon Sep 17 00:00:00 2001 From: Grigory Frolov <2168057+gynsus@users.noreply.github.com> Date: Sun, 30 Aug 2026 13:47:55 +0300 Subject: [PATCH] fix: force Meta page re-selection on connect via auth_type=rerequest --- app/Http/Controllers/Auth/FacebookController.php | 3 +++ app/Http/Controllers/Auth/InstagramFacebookController.php | 3 +++ tests/Feature/Social/FacebookControllerTest.php | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/app/Http/Controllers/Auth/FacebookController.php b/app/Http/Controllers/Auth/FacebookController.php index 8142f6f8f..6b9b6a019 100644 --- a/app/Http/Controllers/Auth/FacebookController.php +++ b/app/Http/Controllers/Auth/FacebookController.php @@ -51,6 +51,9 @@ public function connect(Request $request): Response Socialite::driver($this->driver) ->usingGraphVersion($this->graphVersion()) ->setScopes($this->scopes) + // Meta silently reuses the previous grant (and its page selection), + // so without rerequest a newly created Page never shows up. + ->with(['auth_type' => 'rerequest']) ->redirect() ->getTargetUrl() ); diff --git a/app/Http/Controllers/Auth/InstagramFacebookController.php b/app/Http/Controllers/Auth/InstagramFacebookController.php index d20d32712..a4c9b4a40 100644 --- a/app/Http/Controllers/Auth/InstagramFacebookController.php +++ b/app/Http/Controllers/Auth/InstagramFacebookController.php @@ -65,6 +65,9 @@ public function connect(Request $request): Response ->usingGraphVersion($this->graphVersion()) ->setScopes($this->scopes) ->redirectUrl(route('app.social.instagram-facebook.callback')) + // Meta silently reuses the previous grant (and its page selection), + // so without rerequest a newly created Page never shows up. + ->with(['auth_type' => 'rerequest']) ->redirect() ->getTargetUrl(); diff --git a/tests/Feature/Social/FacebookControllerTest.php b/tests/Feature/Social/FacebookControllerTest.php index 8b3e627db..885c66f49 100644 --- a/tests/Feature/Social/FacebookControllerTest.php +++ b/tests/Feature/Social/FacebookControllerTest.php @@ -27,6 +27,7 @@ $driverMock = Mockery::mock(); $driverMock->shouldReceive('usingGraphVersion')->andReturnSelf(); $driverMock->shouldReceive('setScopes')->andReturnSelf(); + $driverMock->shouldReceive('with')->with(['auth_type' => 'rerequest'])->once()->andReturnSelf(); $driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([ 'getTargetUrl' => 'https://www.facebook.com/v25.0/dialog/oauth?test=1', ])); @@ -646,6 +647,7 @@ $driverMock = Mockery::mock(); $driverMock->shouldReceive('usingGraphVersion')->andReturnSelf(); $driverMock->shouldReceive('setScopes')->andReturnSelf(); + $driverMock->shouldReceive('with')->with(['auth_type' => 'rerequest'])->andReturnSelf(); $driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([ 'getTargetUrl' => 'https://www.facebook.com/v25.0/dialog/oauth?test=1', ])); @@ -673,6 +675,7 @@ $driverMock = Mockery::mock(); $driverMock->shouldReceive('usingGraphVersion')->andReturnSelf(); $driverMock->shouldReceive('setScopes')->andReturnSelf(); + $driverMock->shouldReceive('with')->with(['auth_type' => 'rerequest'])->andReturnSelf(); $driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([ 'getTargetUrl' => 'https://www.facebook.com/v25.0/dialog/oauth?test=1', ])); @@ -699,6 +702,7 @@ $driverMock = Mockery::mock(); $driverMock->shouldReceive('usingGraphVersion')->andReturnSelf(); $driverMock->shouldReceive('setScopes')->andReturnSelf(); + $driverMock->shouldReceive('with')->with(['auth_type' => 'rerequest'])->andReturnSelf(); $driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([ 'getTargetUrl' => 'https://www.facebook.com/v25.0/dialog/oauth?test=1', ]));