Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HybridAuth: How to ask for extra permission for exisiting user?

I am using HybridAuth to allow users to login to my site using their Facebook accounts. During the first login, as usual, Facebook asks the user to grand permissions to my application. As I want the lowest acceptance threshold possible, I don't want to ask users during this login process to grant permissions, that are needed to post on their walls. But I would like to provide this as an extra feature.

For example, if an user posts a certain content type, I would like to ask him, if he wants this content be posted on his wall. To make this possible, I have to ask for the permission to post on the Facebook wall when the user is already logged in.

Is this possible with HybridAuth?

like image 674
user5950 Avatar asked Nov 09 '22 03:11

user5950


1 Answers

Possible? Yes, HybridAuth supports the FaceBook Perm API which allows you to control what permissions there are. The way to do this is simple. in the "scope" array you enter in the permissions you will be asking for and needing. There is no way to pretend your only using a few,but in reality you are using all of them. I will give give you some sample code (in PHP) as a rough 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 what permissions you are going to use in your application. To some it all up, yes it can happen on Hybrid Auth. But at the same time it depends on what you are using, you might be better off using the Facebook API and C+. For more details please refer back to: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 additional help, please comment below and if I wasn't clear enough I am sorry for inconvenience. Enjoy your day!

like image 92
makertech81 Avatar answered Nov 15 '22 06:11

makertech81