HybridAuth: how to request additional permission for the user?

I use HybridAuth so that users can log in to my site using their Facebook accounts. During the first login, as usual, Facebook asks the user for large permissions for my application. Since I want the minimum acceptable threshold to be allowed, I do not want to ask users during this registration process to provide the permissions that are necessary for publication on their walls. But I would like to introduce this as an additional feature.

For example, if a user publishes a certain type of content, I would like to ask him if he wants this content to be published on his wall. To make this possible, I must ask permission to publish on the Facebook wall when the user is already logged in.

Is this possible with HybridAuth?

+5
source share
1 answer

Possible? Yes, HybridAuth supports the FaceBook Perm API, which allows you to control which permissions are available. The way to do this is simple. in the scope array, you enter the permissions that you need and which you need. Itโ€™s impossible to pretend that you are using only a few, but in fact you are using all of them. I will give you sample code (in PHP) as an approximate idea of โ€‹โ€‹what it is:

<?php $config = array( "base_url" => "http://mywebsite.com/path/to/hybridauth/", "providers" => array ( "Facebook" => array ( "enabled" => true, "keys" => array ( "id" => "PUT_YOURS_HERE", "secret" => "PUT_YOURS_HERE" ), "scope" => "email, user_about_me, user_birthday, user_hometown", // optional "display" => "popup" // optional ))); require_once( "/path/to/hybridauth/Hybrid/Auth.php" ); $hybridauth = new Hybrid_Auth( $config ); $adapter = $hybridauth->authenticate( "Facebook" ); $user_profile = $adapter->getUserProfile(); 

As you can see, the scope array contains the permissions that you are going to use in your application. For some, thatโ€™s all, yes, it can happen on Hybrid Auth. But at the same time, it depends on what you use, you might be better off using the Facebook and C + APIs. For more information, please contact: http://hybridauth.sourceforge.net/userguide/IDProvider_info_Facebook.html And for the Facebook API: http://developers.facebook.com/docs/reference/dialogs#display

If you need more help, please comment below, and if I was not clear enough, I regret the inconvenience. Enjoy your day!

+1
source

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


All Articles