{"record":{"id":"6c847b4b9427ef5b","repo":"BookStackApp/BookStack","slug":"errors-social-login-bad-response","errorCode":null,"errorMessage":"errors.social_login_bad_response","messagePattern":"errors\\.social_login_bad_response","errorType":"exception","errorClass":"SocialSignInException","httpStatus":null,"severity":"warning","filePath":"app/Access/Controllers/SocialController.php","lineNumber":68,"sourceCode":"        return $this->socialAuthService->startRegister($socialDriver);\n    }\n\n    /**\n     * The callback for social login services.\n     *\n     * @throws SocialSignInException\n     * @throws SocialDriverNotConfigured\n     * @throws UserRegistrationException\n     */\n    public function callback(Request $request, string $socialDriver)\n    {\n        if (!session()->has('social-callback')) {\n            throw new SocialSignInException(trans('errors.social_no_action_defined'), '/login');\n        }\n\n        // Check request for error information\n        if ($request->has('error') && $request->has('error_description')) {\n            throw new SocialSignInException(trans('errors.social_login_bad_response', [\n                'socialAccount' => $socialDriver,\n                'error'         => $request->input('error_description'),\n            ]), '/login');\n        }\n\n        $action = session()->pull('social-callback');\n\n        // Attempt login or fall-back to register if allowed.\n        $socialUser = $this->socialAuthService->getSocialUser($socialDriver);\n        if ($action === 'login') {\n            try {\n                return $this->socialAuthService->handleLoginCallback($socialDriver, $socialUser);\n            } catch (SocialSignInAccountNotUsed $exception) {\n                if ($this->socialAuthService->drivers()->isAutoRegisterEnabled($socialDriver)) {\n                    return $this->socialRegisterCallback($socialDriver, $socialUser);\n                }\n\n                throw $exception;","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/app/Access/Controllers/SocialController.php#L50-L86","documentation":"SocialSignInException thrown in SocialController::callback when the OAuth/social provider returned an 'error' and 'error_description' query parameter. The library surfaces the provider's own failure message, tagged with the driver name, and redirects the user back to /login.","triggerScenarios":"The identity provider redirects back to the callback URL with error parameters, e.g. user denied consent, invalid client_id/secret, misconfigured redirect URI, or provider-side account errors.","commonSituations":"User clicks 'Cancel'/'Deny' on the consent screen; redirect URI registered in the provider console does not exactly match APP_URL callback; provider app disabled or credentials rotated; scope changes rejected by the provider.","solutions":["Read the included error_description for the provider's reason and fix the underlying provider-side issue","Verify the callback/redirect URI registered with the provider exactly matches the app's generated callback URL","Check client ID/secret configuration (service options and .env) are valid and current","Re-run the login and grant consent when the error is user_access_denied"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if ($request->has('error') && $request->has('error_description')) {\n    \\Log::warning('Social login error', ['driver' => $driver, 'desc' => $request->input('error_description')]);\n}","typeGuard":null,"tryCatchPattern":"try {\n    $result = $socialController->callback($request, $driver);\n} catch (\\BookStack\\Access\\Exceptions\\SocialSignInException $e) {\n    return redirect('/login')->with('error', $e->getMessage());\n}","preventionTips":["Double-check the provider console redirect URI matches APP_URL exactly","Rotate-test client credentials after any secret change","Monitor error_description values for recurring consent/configuration issues"],"tags":["oauth","social-login","provider-error"],"backgroundTag":"oauth-provider-error-response","analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}