Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Again UniqueID is required. Facebook oauth login problem.

I've got the same problem as discussed before but I can't solve it

vanilla 2.1.1 Tried: 1. * Facebook dev app - not in sandbox mode and set in website mode with urls 2. * correct values of Application ID & Application Secret 3. * checked php enabled cUrl, enabled OpenSSL 4. * updated in class.facebook.plugin.php as said here

public function GetProfile($AccessToken) {
      $Url = "https://graph.facebook.com/me?access_token=$AccessToken";
//      $C = curl_init();
//      curl_setopt($C, CURLOPT_RETURNTRANSFER, TRUE);
//      curl_setopt($C, CURLOPT_SSL_VERIFYPEER, FALSE);
//      curl_setopt($C, CURLOPT_URL, $Url);
//      $Contents = curl_exec($C);
//      $Contents = ProxyRequest($Url);
      $Contents = $this->file_get_contents_curl($Url);
      $Profile = json_decode($Contents, TRUE);
      return $Profile;
   }
    function file_get_contents_curl($url) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
    curl_setopt($ch, CURLOPT_URL, $url);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
  }
Still got that UniqueID is required.

I'm stuck.

«1

Comments

  • BleistivtBleistivt Moderator
    edited September 2014

    Can you verify that your application ID and secret appears in your config.php?

    You could also try using the facebook plugin from here:
    https://github.com/vanilla/vanilla/tree/master/plugins/Facebook

    Don't make any changes to the code, the change you linked to was suggested by someone in 2011, a lot has changed since then.

  • Yes. I've got lines in config.php

    $Configuration['Plugins']['Facebook']['ApplicationID'] = 'xxxx';
    $Configuration['Plugins']['Facebook']['Secret'] = 'xxxx';
    

    I've got that latest plugin. not edited.

    I had recreate Facebook app again step by step from here http://blog.vanillaforums.com/facebook-application-for-vanillaforums-sso/
    It's green (not in sand box) and site is set correct

    same UniqueID is required.

  • Are any of the other social login plugins like Twitter or Google working?

    If yes, temporarily add this to line 341 of the plugin:

    file_put_contents('log.txt', print_r($Profile, true));

    and inspect what has been written to the log.txt, there should be a field "id"

  • Yes Twitter and Google Plus auth are working

    I have no log.txt. It doesn't appearing in anywhere

  • Change the 'log.txt' into some path you know thats writeable by php, for example the uploads folder:

    file_put_contents(PATH_UPLOADS.'/facebooktest.txt', print_r($Profile, true));

    and on a second thought, add it before line 523 (right before the return $Profile;)
    Then try to log in.

    Also enable debugging by adding this to your config:

    $Configuration['Debug'] = TRUE;

    This is just to capture the data you are getting back from facebook, if anything at all.

  • It doesn't create facebooktest.txt.
    Uploads folder is accessible. profile picture I can change and new pic can be uploaded.

  • BleistivtBleistivt Moderator
    edited September 2014

    Hm, then I really don't know what to do.
    I just tested this on an installation with working facebook social sign in and got back something like:

    Array
    (
        [id] => 1111111111111111111
        [email] => email@adress
        [first_name] => FirstName
        [gender] => male
        [last_name] => LastName
        [link] => https://www.facebook.com/user.name
        [locale] => de_DE
        [name] => FirstName LastName
        [timezone] => 2
        [updated_time] => 2014-04-25T16:30:39+0000
        [username] => user.name
        [verified] => 1
    )
    

    Have you enabled debugging, do you get any debug messages?

  • myemye New
    edited September 2014

    I think the problem is that It just don't go up to the function GetProfile() that's why the log doesn't generate

    debugging is active

    it give me an error
    "There was an error with the Facebook connection.
    UniqueID is required."

    $AccessToken return empty

  • myemye New
    edited September 2014

    Error is generated in line 447

     // Get the profile.
          try {
             $Profile = $this->GetProfile($AccessToken);
          } catch (Exception $Ex) {
             if (!isset($NewToken)) {
                // There was an error getting the profile, which probably means the saved access token is no longer valid. Try and reauthorize.
                if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
                   Redirect($this->AuthorizeUri());
                } else {
                   $Sender->SetHeader('Content-type', 'application/json');
                   $Sender->DeliveryMethod(DELIVERY_METHOD_JSON);
                   $Sender->RedirectUrl = $this->AuthorizeUri();
                }
             } else {
      447->               $Sender->Form->AddError('There was an error with the Facebook connection!');
             }
          }
    
  • It's either one of 2 things:

    1. Your server can't connect to facebook, which is unlikely, since the other plugins are working.
    2. Facebook rejects your auth credentials.

    You could log the response you get from facebook the same way i proposed above in the GetAccessToken function (look whats in the variable $Contents).

    However, if facebook returned an error, vanilla would show it.

  • $Info = curl_getinfo($C); from GetAccessToken() return that

    Array
    (
        [url] => https://graph.facebook.com/oauth/access_token?client_id=139939810008511&client_secret=207bs6411234627a6e09b1566ae80c&code=AQAc62UXWTWeYT98ckbSi6MyRDMi_P_bDq75ViReLsumQF4BZVx_a_9duCmLNS51cVv_uR8KAli0ya0XXiUiH_15BeO7bSd1_OOvN9FL_geBIYmnV5eCiZuIKJPUrH3V0Uhp8iKj-_CwcFXwO2z5-JtN8iyJ9xxFUzBF0d9f_fUSEOzqjIYZWUhSz7d1XQLf_x-vvk3KS3eIT06TZPD8VFFA4K1OE7VIjZfBeRlNx70zePTyNJuKqVLbQDETKwDhrZtvnfAcuQ8q-xYcYl7DpPzJnYH9Oc3CRY6ULl8h77yDOIP8PA3WNMVAUKgFIQyYV7k&redirect_uri=http%3A%2F%2Fwww.aquastaff.com%2Fentry%2Fconnect%2Ffacebook%3FTarget%3D%252F
        [content_type] => 
        [http_code] => 0
        [header_size] => 0
        [request_size] => 0
        [filetime] => -1
        [ssl_verify_result] => 0
        [redirect_count] => 0
        [total_time] => 0
        [namelookup_time] => 0.000195
        [connect_time] => 0
        [pretransfer_time] => 0
        [size_upload] => 0
        [size_download] => 0
        [speed_download] => 0
        [speed_upload] => 0
        [download_content_length] => -1
        [upload_content_length] => -1
        [starttransfer_time] => 0
        [redirect_time] => 0
        [redirect_url] => 
        [primary_ip] => 127.0.0.1
        [certinfo] => Array
            (
            )
    
    )
    

    [primary_ip] => 127.0.0.1 ????

    $Contents = curl_exec($C);

    but print_r($Contents, true) seem like empty

  • Please remove your application secret and accesstoken from the info above.

    Seems like you are trying to connect from localhost? Facebook doesn't allow that.

  • myemye New
    edited September 2014



    http://www.aquastaff.com/

    I'm trying from here

    application secret and access token are distorted

    1.tiff 67.9K
    2.tiff 125.5K
  • Looks like you are not getting anything back from the curl call.
    Contact your hoster and ask about the curl functions, which ones are enabled, if there are any restrictions and if OpenSSL is enabled.

  • myemye New
    edited September 2014

    they have curl and openssl enabled. But I send a ticker to hosted. Which version of PHP is better? 5.2, 5.3, 5.4, or 5.5? I've got option to choose from.

  • Use 5.4 or 5.5 (5.4 will be required in the future)

  • edited September 2014

    @Bleistivt said:
    Looks like you are not getting anything back from the curl call.
    Contact your hoster and ask about the curl functions, which ones are enabled, if there are any restrictions and if OpenSSL is enabled.

    Already tall him problem was on curl call...Why don't u test it using another host :D

  • @Bleistivt said:
    Please remove your application secret and accesstoken from the info above.

    In vanilla Facebook plugin, It's very easy to find someone Application ID,Application Secret using small trick B)

  • Any recommendation on free hosting to try?

    Of course I altered Application I and Application Secret. They are not real.

  • try to echo

    echo $Contents = curl_exec($C);

    if didn't get anything,that mean u host not yet supporting curl url

    (that was the method,how i discovered above error ;) )

Sign In or Register to comment.