Thomas Rbt
Thomas Rbt

Reputation: 1536

Oauth permission each login, even if accepted first

My website use oauth from google and facebook.

It works fine, but when users come from google, the login is transparent: they are redirected to a page from google which auto redirect after on my website.

But with Facebook, it always open a window asking permissions, even if I accepted them before, so it's an useless step for my customers when they log into my website.

Here is where my users are redirected when they clic "login with facebook" when they already created an account using facebook oauth: https://i.imgur.com/ap5h8ku.png

This is the code I use

$app_id = "123456789";
$app_secret = "8zpsuzj6d5z4xxxxxx";
$redirectURL = 'https://www.my-website.com/controller/oauthController.php?auth=facebook';


require_once ROOT.'/files/lib/Facebook/autoload.php';

$provider = new \League\OAuth2\Client\Provider\Facebook([
    'clientId'          => $app_id,
    'clientSecret'      => $app_secret,
    'redirectUri'       => $redirectURL,
    'graphApiVersion'   => 'v2.10',
]);



// If we don't have an authorization code then get one
$authUrl = $provider->getAuthorizationUrl([
    'scope' => ['email', 'public_profile'],
]);

        
header("Location: ".$authUrl);
exit;

Thanks for help. I tested some sites using facebook and when the first prompt asking authorisazion is accepted, we can login/logout without being redirected to facebook modal ...

Upvotes: 0

Views: 32

Answers (0)

Related Questions