artdarek / oauth-4-laravel

OAuth Service Provider for Laravel 4
685 stars 217 forks source link

delete app in facebook #156

Closed ppeinsold closed 8 years ago

ppeinsold commented 8 years ago

Hi! I have implemented a facebook oauth login with oauth-4-laravel. It works fine. But one problem remains: When a user clicks on the "login with facebook" button then the facebook page opens and shows the requested permissions of my app. Now the user can view the permissions in detail and can uncheck "email". This is a big problem because i need the email for the login and/or registration. Now my website wants to create a user and wants to get the email. I can catch the exception if the email is not accessible, but the problem is, that the user has now already registered my app in his facebook apps. So what happens now is, that if the user tries again to login (and maybe wants now to allow me to read his email) the permission page is not shown again because the app is already registered.

What I want to do is, if I catch the exception I want to delete the facebook app from the user account. I know I can do that with other libraries, but how to do that with this library?

Should be something like: $fb = OAuth::consumer('Facebook', ); ... catch Exception ... $fb->request( '/me' )->delete();

ppeinsold commented 8 years ago

I think I have to do the following request of the Graph API: FB.api("/me/permissions","DELETE",function(response){ console.log(response); //gives true on app delete success });

How can I do that with oauth-4-laravel? $fb->request( '/me/permissions');

But where to put the "DELETE" Parameter? Thanks!

ppeinsold commented 8 years ago

Ok, I looked into the code of Lusitanian/PHPoAuthLib. It's that simple:

$fb->request( '/me/permissions', 'DELETE');

This request deletes/revokes the permissions of your facebook app given by the facebook user. So the app does not appear in the user's settings/apps screen of facebook anymore. The user has to give permissions again if he does a facebook login next time.