Facebook OAuth issue


#1

I am getting error while trying to implement Facebook OAuth in Ionic app.

This is how my request url looks like:
https://df-apiurl.com/api/v2/user/session?oauth_callback=true&service=facebook&code=**********&state=********

Here is the error response.
The relevant part might be:

“message”:"Client error: POST https://graph.facebook.com/oauth/access_token resulted in a 400 Bad Request response:\n{“error”:{“message”:“Error validating verification code. Please make sure your redirect_uri is identical to the one you (truncated…)\n”

But here is the full error message just in case.

{“error”:{“context”:null,“message”:"Client error: POST https://graph.facebook.com/oauth/access_token resulted in a 400 Bad Request response:\n{“error”:{“message”:“Error validating verification code. Please make sure your redirect_uri is identical to the one you (truncated…)\n”,“code”:400,“trace”:[“0 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))”,“1 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))”,“2 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)”,“3 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/promises/src/TaskQueue.php(61): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()”,“4 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true)”,“5 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()”,“6 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/promises/src/Promise.php(266): GuzzleHttp\Promise\Promise->waitIfPending()”,“7 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()”,“8 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()”,“9 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/guzzle/src/Client.php(129): GuzzleHttp\Promise\Promise->wait()”,“10 /opt/bitnami/apps/dreamfactory/htdocs/vendor/guzzlehttp/guzzle/src/Client.php(87): GuzzleHttp\Client->request(‘post’, ‘https://graph.f…’, Array)”,“11 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/socialite/src/Two/FacebookProvider.php(77): GuzzleHttp\Client->__call(‘post’, Array)”,“12 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/socialite/src/Two/FacebookProvider.php(77): GuzzleHttp\Client->post(‘https://graph.f…’, Array)”,“13 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/socialite/src/Two/AbstractProvider.php(202): Laravel\Socialite\Two\FacebookProvider->getAccessTokenResponse(‘AQB6vh4ZHq1oYQn…’)”,“14 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-oauth/src/Services/BaseOAuthService.php(91): Laravel\Socialite\Two\AbstractProvider->user()”,“15 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-core/src/Resources/UserSessionResource.php(86): DreamFactory\Core\OAuth\Services\BaseOAuthService->handleOAuthCallback()”,“16 [internal function]: DreamFactory\Core\Resources\UserSessionResource->handlePOST()”,“17 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-core/src/Components/RestHandler.php(267): call_user_func(Array)”,“18 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-core/src/Components/RestHandler.php(173): DreamFactory\Core\Components\RestHandler->processRequest()”,“19 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-core/src/Components/RestHandler.php(220): DreamFactory\Core\Components\RestHandler->handleRequest(Object(DreamFactory\Core\Utility\ServiceRequest), ‘’)”,“20 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-core/src/Components/RestHandler.php(168): DreamFactory\Core\Components\RestHandler->handleResource(Array)”,“21 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-core/src/Services/BaseRestService.php(74): DreamFactory\Core\Components\RestHandler->handleRequest(Object(DreamFactory\Core\Utility\ServiceRequest), ‘session’)”,“22 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(17036): DreamFactory\Core\Services\BaseRestService->handleRequest(Object(DreamFactory\Core\Utility\ServiceRequest), ‘session’)”,“23 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(17008): DreamFactory\Http\Controllers\RestController->handleService(‘v2’, ‘user’, ‘session’)”,“24 [internal function]: DreamFactory\Http\Controllers\RestController->handlePOST(‘v2’, ‘user’, ‘session’)”,“25 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9093): call_user_func_array(Array, Array)”,“26 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9155): Illuminate\Routing\Controller->callAction(‘handlePOST’, Array)”,“27 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9135): Illuminate\Routing\ControllerDispatcher->call(Object(DreamFactory\Http\Controllers\RestController), Object(Illuminate\Routing\Route), ‘handlePOST’)”,“28 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“29 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“30 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(17209): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“31 [internal function]: DreamFactory\Http\Middleware\AccessCheck->handle(Object(Illuminate\Http\Request), Object(Closure))”,“32 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9627): call_user_func_array(Array, Array)”,“33 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))”,“34 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“35 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“36 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9612): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“37 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9136): Illuminate\Pipeline\Pipeline->then(Object(Closure))”,“38 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9123): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(DreamFactory\Http\Controllers\RestController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), ‘handlePOST’)”,“39 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(8191): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), ‘DreamFactory\\Ht…’, ‘handlePOST’)”,“40 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(8178): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))”,“41 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(7892): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))”,“42 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“43 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“44 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“45 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9612): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“46 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(7893): Illuminate\Pipeline\Pipeline->then(Object(Closure))”,“47 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(7884): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))”,“48 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(7874): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))”,“49 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(2416): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))”,“50 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))”,“51 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“52 /opt/bitnami/apps/dreamfactory/htdocs/app/Http/Middleware/AuthCheck.php(178): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“53 [internal function]: DreamFactory\Http\Middleware\AuthCheck->handle(Object(Illuminate\Http\Request), Object(Closure))”,“54 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9627): call_user_func_array(Array, Array)”,“55 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))”,“56 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“57 /opt/bitnami/apps/dreamfactory/htdocs/vendor/barryvdh/laravel-cors/src/HandleCors.php(42): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“58 [internal function]: Barryvdh\Cors\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))”,“59 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9627): call_user_func_array(Array, Array)”,“60 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))”,“61 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“62 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(17306): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“63 [internal function]: DreamFactory\Http\Middleware\FirstUserCheck->handle(Object(Illuminate\Http\Request), Object(Closure))”,“64 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9627): call_user_func_array(Array, Array)”,“65 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))”,“66 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“67 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(13076): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“68 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))”,“69 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9627): call_user_func_array(Array, Array)”,“70 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))”,“71 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“72 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(11622): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“73 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))”,“74 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9627): call_user_func_array(Array, Array)”,“75 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))”,“76 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“77 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(12815): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“78 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))”,“79 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9627): call_user_func_array(Array, Array)”,“80 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))”,“81 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“82 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(12752): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“83 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))”,“84 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9627): call_user_func_array(Array, Array)”,“85 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))”,“86 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“87 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(3271): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“88 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))”,“89 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9627): call_user_func_array(Array, Array)”,“90 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))”,“91 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“92 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))”,“93 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9612): call_user_func(Object(Closure), Object(Illuminate\Http\Request))”,“94 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(2363): Illuminate\Pipeline\Pipeline->then(Object(Closure))”,“95 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(2347): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))”,“96 /opt/bitnami/apps/dreamfactory/htdocs/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))”,“97 {main}”]}}


#2

Hello @mrvipinkashyap,

May I ask you to double check the url in the redirect from Facebook? We find that errors in that is a common issue we see.

Also, have you read our resources and documentation on it?

Thanks,
@AlexBowen


#3

@AlexBowen Thanks for your reply.
I solved issue in my case with answer here:

In case someone else comes across similar issue, please try adding following in both dreamfactory OAuth service redirect url and facebook redirect url:

http://my_domain/dreamfactory/dist/index.html?service=facebook


#4

Glad to hear it. Thanks for letting the community know and sharing your solution!

Thanks,
@AlexBowen