daviddesberg / PHPoAuthLib

PHP 5.3+ oAuth 1/2 Client Library
Other
1.08k stars 454 forks source link

Error login with facebook: Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request #520

Open joseparra97 opened 7 years ago

joseparra97 commented 7 years ago

Hi, I'm using https://github.com/oriceon/oauth-5-laravel this is a simple laravel 5 service provider (wrapper) for Lusitanian/PHPoAuthLib which provides oAuth support in PHP 5.4+ and is very easy to integrate with any project which requires an oAuth client.

I am trying to login with facebook but I get this error: image

This is my code:

public function loginWithFacebook(Request $request)
    {
        // get data from request
        $code = $request->get('code');

        // get fb service
        $OAuth = new \OAuth();
        $OAuth::setHttpClient('CurlClient');
        $fb = $OAuth::consumer('Facebook', 'http://logos.dev/api/auth/facebook/');

        // check if code is valid

        // if code is provided get user data and sign in
        if (!is_null($code)) {
            // This was a callback request from facebook, get the token
            $token = $fb->requestAccessToken($code);
            // Send a request with it
            $result = json_decode($fb->request('/me'), true);
            dd($result);
        } else {
            // get fb authorization
            $url = $fb->getAuthorizationUri();

            // return to facebook login url
            return redirect((string)$url);
        }
    }

This is my facebook settings:

image

kibi commented 6 years ago

Please see issue 512, it seems you have the same issue.