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.

jsConnect help

edited February 2012 in Vanilla 2.0 - 2.8

hi,

I've just setup vanilla and I am trying to use jsConnect to combine my custom built site with the forum.

I've created a auth file which is an exact copy of the example file in the php code library, the require file is within the forum directory (again same file from the php code library).

but I can't seem to get it to work, calling the auth file directly gives a blank page and the site won't log me in.

any help will be greatly appreciated.
Shedh

Best Answer

Answers

  • ToddTodd Vanilla Staff

    You need to plug in your own user information that is specific to your site. Have you done this or have you really put an exact copy of the auth file on your site?

  • edited February 2012

    I amended the auth file to work with my own framework, i've added a snippet below. I've commented out my code, but I assure you that my code does work

    <?php
    include('./forum/jsConnectFunctions.php');
    include('./prependFile.php');
    
    ~~~CHECK IF SESSION EXISTS~~~
    
    // 1. Get your client ID and secret here. These must match those in your jsConnect settings.
    $clientID = CLIENT ID
    $secret = SECRET
    
    // 2. Grab the current user from your session management system or database here.
    $signedIn = true; // this is just a placeholder
    
    ~~~GRAB USER INFO FROM DB AND USE ARRAY $userinfo & $userid~~~
    
    // 3. Fill in the user information in a way that Vanilla can understand.
    $user = array();
    
    if ($signedIn) {
       // CHANGE THESE FOUR LINES.
       $user['uniqueid'] = $userid;
       $user['name'] = $userinfo['username'];
       $user['email'] = $userinfo['email'];
       $user['photourl'] = $userinfo['display_pic'];
    }
    
    // 4. Generate the jsConnect string.
    
    // This should be true unless you are testing. 
    // You can also use a hash name like md5, sha1 etc which must be the name as the connection settings in Vanilla.
    $secure = true; 
    
    WriteJsConnect($user, $_GET, $clientID, $secret, $secure);
    
  • ToddTodd Vanilla Staff

    If you call the auth page directly you should never get a blank page. Try turning on error reporting to see if you've got an error in your page:

    error_reporting(E_ALL);
    ini_set('display_errors', 'on');
    ini_set('track_errors', 1);
    
  • My error logs don't pick anything up, It seems to be something with the line

    if (!defined('APPLICATION')) exit();

    If that line is removed, the login info shows up but won't login because of a "Signature Invalid." error.

  • ToddTodd Vanilla Staff
    via Email
    That was an oversight that crept in from the main application. I've removed that line in the repository.

    You're getting closer now. Have you matched the client IDs and secrets in Vanilla and your page? Once you have, click on the test link in Vanilla beside your connection.
  • now am getting

    test({"error":"access_denied","message":"Signature invalid."})

  • is something wrong with the functions file, as the hash is obviously being outputted incorrectly

  • ToddTodd Vanilla Staff

    Have you matched the client IDs and secrets in Vanilla and your page?

  • yes, double checked all codes are matching

  • Answer ✓

    guess it works now, I used the updated code on github

  • was there ever a resolution to this issue? I'm having the same problem

  • @mnelson77‌ Please start a new thread detailing your issue.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.