Re-requesting denied permissions for Facebook (auth_type = rerequest) does not work

We are developing a Facebook application with PHP SDK 3.2.3 and Javascript SDK. I need to ask permission to post on the wall if they have denied access to posting on Facebook when they log in.

As the documentation says:

[...] Your application must re-request the denied permissions with special processing. [...]

[...] Web applications must explicitly pass a new parameter in the Login: auth_type: rerequest dialog box. Detailed information on how the new parameter works on the Internet is described in our documentation on using the JavaScript SDK on the Internet.

but we tried with this request:

https://www.facebook.com/dialog/oauth?auth_type=rerequest&client_id=1...7&redirect_uri=MY_PAGE&state=a1f4412db0617ef1a620ac1d1ebc2af8&sdk=php-sdk-3.2.3&campaign_page_page_page_p

but users are redirected directly to the MY_PAGE URL, and permissions are not re-requested.

Can this (incorrect) behavior be related to the fact that the application is a test application?

+5
source share
3 answers

In js sdk, I directly call the login method as follows:

FB.login( function( response ) { if (response.status == 'connected') { } },{ scope: 'email,public_profile', return_scopes: true, auth_type: 'rerequest' }); 

On the server side, I use accesstoken to request user information on Facebook. If the letter is not provided, I return an error message informing the user that he needs to log in again and provide the email. When they press the login button again due to the auth_type: 'rerequest' part , they will be requested again for permissions.

+3
source

Assuming the user rejected email permission using FacebookSDK and laravel, where $ fb is an instance of FacebookSDK, you can:

 return redirect()->to($fb->getReRequestUrl(['email'])); 

without FacebookSDK:

 return redirect('https://www.facebook.com/v2.10/dialog/oauth?' . build_query([ 'client_id' => config('services.facebook.client_id'), 'redirect_uri' => 'http://localhost:8000/social_auth/facebook/callback', 'state' => $state, 'auth_type' => 'rerequest', 'scope' => 'email' ])); 
0
source

In the php SDK (3.x) auth_type rerequest can be sent to Facebook via the getLoginUrl parameter:

 $loginUrl = $facebook->getLoginUrl(array( 'scope' => 'public_profile, user_friends, email', 'redirect_url' => 'http://www.yourul.com/example.php', 'auth_type' => 'rerequest', )); 
-1
source

Source: https://habr.com/ru/post/1203306/


All Articles