{"action":"created","issue":{"url":"https://api.github.com/repos/adamwathan/eloquent-oauth/issues/36","labels_url":"https://api.github.com/repos/adamwathan/eloquent-oauth/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/adamwathan/eloquent-oauth/issues/36/comments","events_url":"https://api.github.com/repos/adamwathan/eloquent-oauth/issues/36/events","html_url":"https://github.com/adamwathan/eloquent-oauth/issues/36","id":58736722,"number":36,"title":"Authorization Error","user":{"login":"babatundeakinse","id":8863223,"avatar_url":"https://avatars.githubusercontent.com/u/8863223?v=3","gravatar_id":"","url":"https://api.github.com/users/babatundeakinse","html_url":"https://github.com/babatundeakinse","followers_url":"https://api.github.com/users/babatundeakinse/followers","following_url":"https://api.github.com/users/babatundeakinse/following{/other_user}","gists_url":"https://api.github.com/users/babatundeakinse/gists{/gist_id}","starred_url":"https://api.github.com/users/babatundeakinse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babatundeakinse/subscriptions","organizations_url":"https://api.github.com/users/babatundeakinse/orgs","repos_url":"https://api.github.com/users/babatundeakinse/repos","events_url":"https://api.github.com/users/babatundeakinse/events{/privacy}","received_events_url":"https://api.github.com/users/babatundeakinse/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-24T13:17:58Z","updated_at":"2015-02-24T13:53:28Z","closed_at":null,"body":"Authorization was attempted with invalid [This Happens Even When OAuth Returns Valid User Details]\r\nI have added the code below..\r\n```php\r\ntry \r\n\t    {\r\n\t        OAuth::login('facebook', function($user, $details) {\r\n\r\n\t        \tvar_dump($details);\r\n\t        \t$checkVal =   $user->activated;\r\n\t\t\t    $user->username = strtolower ( $details->firstName . '.' . $details->lastName );\r\n\t\t\t    $user->name = $details->firstName . ' ' . $details->lastName;\r\n\t\t\t    $user->image_url = $details->imageUrl;\r\n\t\t\t    $user->email = $details->email;\r\n\t\t\t    $user->gender = $details->gender;\r\n\t\t\t    $user->activated = 1;\r\n\t\t\t    $user->save();\r\n\r\n\t\t\t\t$userRole = Role::where('name', '=', 'super_admin')->first();\r\n\r\n\t\t\t\tif($checkVal!=1)\r\n\t\t\t\t{\r\n\t\t\t\t\t//$userRole = Role::find(1);\r\n\t\t\t    \t$user->roles()->attach($userRole);\r\n\t\t\t\t}\r\n\t\t\t    \r\n\t\t\t});\r\n\r\n\t    } \r\n\t    catch (ApplicationRejectedException $e) \r\n\t    {\r\n\t        // User rejected application\r\n\t        return Response::json(['success' => false,'message'=>'User Authorization Rejected']);\r\n\t    } \r\n\t    catch (InvalidAuthorizationCodeException $e)\r\n\t    {\r\n\t    \treturn Response::json(['success' => false,'message'=>'Invalid Autorization Code']);\r\n\t        // Authorization was attempted with invalid\r\n\t        // code,likely forgery attempt\r\n\t    }\r\n\r\n\t    // Current user is now available via Auth facade\r\n\t    $user = Auth::user();\r\n\r\n\t    return Redirect::to('admin/tags');\r\n```"},"comment":{"url":"https://api.github.com/repos/adamwathan/eloquent-oauth/issues/comments/75759342","html_url":"https://github.com/adamwathan/eloquent-oauth/issues/36#issuecomment-75759342","issue_url":"https://api.github.com/repos/adamwathan/eloquent-oauth/issues/36","id":75759342,"user":{"login":"babatundeakinse","id":8863223,"avatar_url":"https://avatars.githubusercontent.com/u/8863223?v=3","gravatar_id":"","url":"https://api.github.com/users/babatundeakinse","html_url":"https://github.com/babatundeakinse","followers_url":"https://api.github.com/users/babatundeakinse/followers","following_url":"https://api.github.com/users/babatundeakinse/following{/other_user}","gists_url":"https://api.github.com/users/babatundeakinse/gists{/gist_id}","starred_url":"https://api.github.com/users/babatundeakinse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babatundeakinse/subscriptions","organizations_url":"https://api.github.com/users/babatundeakinse/orgs","repos_url":"https://api.github.com/users/babatundeakinse/repos","events_url":"https://api.github.com/users/babatundeakinse/events{/privacy}","received_events_url":"https://api.github.com/users/babatundeakinse/received_events","type":"User","site_admin":false},"created_at":"2015-02-24T13:53:28Z","updated_at":"2015-02-24T13:53:28Z","body":"@adamwathan i have set my username field to unique so everytime i try to login its trying to add another user..\r\n\r\nNext exception 'Illuminate\\Database\\QueryException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'babatunde.akinse' for key 'users_username_unique' (SQL: insert into `users` (`username`, `name`, `image_url`, `email`, `gender`, `activated`, `updated_at`, `created_at`) values (babatunde.akinse, Babatunde Akinse, https://graph.facebook.com/10206366056218512/picture, akinsetunde10@gmail.com, , 1, 2015-02-24 12:52:57, 2015-02-24 12:52:57))' in /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:614\r\nStack trace:\r\n#0 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): Illuminate\\Database\\Connection->runQueryCallback('insert into `us...', Array, Object(Closure))\r\n#1 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php(359): Illuminate\\Database\\Connection->run('insert into `us...', Array, Object(Closure))\r\n#2 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php(316): Illuminate\\Database\\Connection->statement('insert into `us...', Array)\r\n#3 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php(30): Illuminate\\Database\\Connection->insert('insert into `us...', Array)\r\n#4 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1713): Illuminate\\Database\\Query\\Processors\\Processor->processInsertGetId(Object(Illuminate\\Database\\Query\\Builder), 'insert into `us...', Array, 'id')\r\n#5 [internal function]: Illuminate\\Database\\Query\\Builder->insertGetId(Array, 'id')\r\n#6 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(933): call_user_func_array(Array, Array)\r\n#7 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1624): Illuminate\\Database\\Eloquent\\Builder->__call('insertGetId', Array)\r\n#8 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1624): Illuminate\\Database\\Eloquent\\Builder->insertGetId(Array, 'id')\r\n#9 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1594): Illuminate\\Database\\Eloquent\\Model->insertAndSetId(Object(Illuminate\\Database\\Eloquent\\Builder), Array)\r\n#10 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1500): Illuminate\\Database\\Eloquent\\Model->performInsert(Object(Illuminate\\Database\\Eloquent\\Builder), Array)\r\n#11 /home/tumaxide/public_html/debug/app_laravel/app/Http/Controllers/SocialController.php(64): Illuminate\\Database\\Eloquent\\Model->save()\r\n#12 /home/tumaxide/public_html/debug/app_laravel/vendor/adamwathan/eloquent-oauth/src/Authenticator.php(26): App\\Http\\Controllers\\SocialController->App\\Http\\Controllers\\{closure}(Object(App\\Models\\User), Object(AdamWathan\\EloquentOAuth\\ProviderUserDetails))\r\n#13 /home/tumaxide/public_html/debug/app_laravel/vendor/adamwathan/eloquent-oauth/src/OAuthManager.php(41): AdamWathan\\EloquentOAuth\\Authenticator->login('facebook', Object(AdamWathan\\EloquentOAuth\\ProviderUserDetails), Object(Closure))\r\n#14 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(213): AdamWathan\\EloquentOAuth\\OAuthManager->login('facebook', Object(Closure))\r\n#15 /home/tumaxide/public_html/debug/app_laravel/app/Http/Controllers/SocialController.php(75): Illuminate\\Support\\Facades\\Facade::__callStatic('login', Array)\r\n#16 /home/tumaxide/public_html/debug/app_laravel/app/Http/Controllers/SocialController.php(75): AdamWathan\\EloquentOAuth\\Facades\\OAuth::login('facebook', Object(Closure))\r\n#17 [internal function]: App\\Http\\Controllers\\SocialController->Login()\r\n#18 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(246): call_user_func_array(Array, Array)\r\n#19 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(162): Illuminate\\Routing\\Controller->callAction('Login', Array)\r\n#20 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(107): Illuminate\\Routing\\ControllerDispatcher->call(Object(App\\Http\\Controllers\\SocialController), Object(Illuminate\\Routing\\Route), 'Login')\r\n#21 [internal function]: Illuminate\\Routing\\ControllerDispatcher->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))\r\n#22 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))\r\n#23 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))\r\n#24 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(101): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))\r\n#25 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(108): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))\r\n#26 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(67): Illuminate\\Routing\\ControllerDispatcher->callWithinStack(Object(App\\Http\\Controllers\\SocialController), Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request), 'Login')\r\n#27 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php(198): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request), 'App\\Http\\Contro...', 'Login')\r\n#28 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php(131): Illuminate\\Routing\\Route->runWithCustomDispatcher(Object(Illuminate\\Http\\Request))\r\n#29 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(691): Illuminate\\Routing\\Route->run(Object(Illuminate\\Http\\Request))\r\n#30 [internal function]: Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))\r\n#31 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))\r\n#32 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))\r\n#33 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(101): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))\r\n#34 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(693): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))\r\n#35 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))\r\n#36 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(618): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))\r\n#37 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(160): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))\r\n#38 [internal function]: Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))\r\n#39 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))\r\n#40 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(43): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))\r\n#41 /home/tumaxide/public_html/debug/app_laravel/app/Http/Middleware/VerifyCsrfToken.php(17): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))\r\n#42 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(125): App\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))\r\n#43 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(55): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))\r\n#44 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(125): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))\r\n#45 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(61): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))\r\n#46 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(125): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))\r\n#47 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(36): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))\r\n#48 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(125): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))\r\n#49 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(40): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))\r\n#50 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(125): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))\r\n#51 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(42): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))\r\n#52 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(125): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))\r\n#53 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))\r\n#54 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(101): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))\r\n#55 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))\r\n#56 /home/tumaxide/public_html/debug/app_laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(84): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))\r\n#57 /home/tumaxide/public_html/debug/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))\r\n#58 {main} \r\n\r\n"}}