Body: <p>I have implemented vanilla forums as a discussion solution for my website. I have made it embed into my parent site and also setup jsConnect to auto sign in the user if he/she is logged into my parent craft website.</p>
  
  <p>I have used this tutorial to set things up:</p>
  
  <p><a href="http://blog.vanillaforums.com/jsconnect-technical-documentation-for-embedded-sso/" rel="nofollow">http://blog.vanillaforums.com/jsconnect-technical-documentation-for-embedded-sso/</a></p>
  
  <p>I can now sign in to vanilla forums using my craft user but next I also want to assign the group permissions to the user. I will define the roles in vanilla forum to match with the user groups in craft but I have no idea how to use jsConnect to assign user roles. Anybody have any experience with such a problem or can help in any way please do.</p>
  
  <p>My Forum Page:</p>
  
  <pre><code>    {% extends "_layout" %}
  
      {% block content %}
  
      &lt;div class="container"&gt;
          &lt;div id="vanilla-comments"&gt;&lt;/div&gt;
  
          &lt;script type="text/javascript"&gt;
  
          /*** Required Settings: Edit BEFORE pasting into your web page ***/
  
          var vanilla_forum_url = 'http://ght.butter.dev/vanilla'; // The full http url &amp; path to your vanilla forum
          var vanilla_identifier = ''; // Your unique identifier for the content being commented on
          var vanilla_sso = '{{craft.myPlugin.authenticateUser()}}'; // Your SSO string.
  
          /*** DON'T EDIT BELOW THIS LINE ***/
  
          (function() {
          var vanilla = document.createElement('script');
          vanilla.type = 'text/javascript';
          var timestamp = new Date().getTime();
          vanilla.src = vanilla_forum_url + '/js/embed.js';
  
          (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(vanilla);
          })();
  
          &lt;/script&gt;
      &lt;/div&gt;
  
      {% endblock %}
  </code></pre>
  
  <p>My Variable function (craft.myPlugin.authenticateUser()):</p>
  
  <pre><code>public function authenticateUser(){
          $userModel = craft()-&gt;userSession-&gt;getUser();
          $clientID = "[clientId]";
          $secret = "[secret]";
  
          if($userModel)
              $signedIn = true;
  
          $user = array();
  
          if($signedIn)
          {
              $user['uniqueid'] = $userModel-&gt;id;
              $user['name'] = $userModel-&gt;username;
              $user['email'] = $userModel-&gt;email;
              $user['photourl'] = $userModel-&gt;photo;
              $user['client_id'] = $clientID;
          }
  
          $user = json_encode($user);
          $signature_string = base64_encode($user);
          $signature_string = $this-&gt;getStr2Hex($signature_string);
          $timestamp = time();
  
          $signature = hash_hmac("sha1", "{$signature_string} {$timestamp}", $secret);
  
          $result = $signature_string." ".$signature." ".$timestamp." hmacsha1";
  
          return $result;
      }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-13T21:29:58.807Z
Comments.Text: Moin, would you mind sharing the full plugin you have so far? Running into some strange problems here when trying to make the connection secure.
  
  Regarding the roles, here it mentions just "roles" in the callback; [link](http://blog.vanillaforums.com/jsconnect-technical-documentation/), `"roles": "member,administrator"`
Comments.UserDisplayName: tom
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-04T18:22:30.020Z
Comments.Text: I wrote a simple plugin to handle VanillaForums/jsConnect <-> Craft CMS SSO, if you want to use it: https://github.com/khalwat/Vanillaforums
Comments.UserDisplayName: andrew.welch
Tags: <plugin-development><variable>
Title: Vanilla Forum Embedded SSO Export User Groups as Roles
ThreadText: # Vanilla Forum Embedded SSO Export User Groups as Roles
  
  (Asked by: username_0 on 2015-04-21)
  
  I have implemented vanilla forums as a discussion solution for my website. I have made it embed into my parent site and also setup jsConnect to auto sign in the user if he/she is logged into my parent craft website.
  
  I have used this tutorial to set things up:
  
  <http://blog.vanillaforums.com/jsconnect-technical-documentation-for-embedded-sso/>
  
  I can now sign in to vanilla forums using my craft user but next I also want to assign the group permissions to the user. I will define the roles in vanilla forum to match with the user groups in craft but I have no idea how to use jsConnect to assign user roles. Anybody have any experience with such a problem or can help in any way please do.
  
  My Forum Page:
  
  ```
      {% extends "_layout" %}
  
      {% block content %}
  
      <div class="container">
          <div id="vanilla-comments"></div>
  
          <script type="text/javascript">
  
          /*** Required Settings: Edit BEFORE pasting into your web page ***/
  
          var vanilla_forum_url = 'http://ght.butter.dev/vanilla'; // The full http url & path to your vanilla forum
          var vanilla_identifier = ''; // Your unique identifier for the content being commented on
          var vanilla_sso = '{{craft.myPlugin.authenticateUser()}}'; // Your SSO string.
  
          /*** DON'T EDIT BELOW THIS LINE ***/
  
          (function() {
          var vanilla = document.createElement('script');
          vanilla.type = 'text/javascript';
          var timestamp = new Date().getTime();
          vanilla.src = vanilla_forum_url + '/js/embed.js';
  
          (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(vanilla);
          })();
  
          </script>
      </div>
  
      {% endblock %}
  
  ```
  
  My Variable function (craft.myPlugin.authenticateUser()):
  
  ```
  public function authenticateUser(){
          $userModel = craft()->userSession->getUser();
          $clientID = "[clientId]";
          $secret = "[secret]";
  
          if($userModel)
              $signedIn = true;
  
          $user = array();
  
          if($signedIn)
          {
              $user['uniqueid'] = $userModel->id;
              $user['name'] = $userModel->username;
              $user['email'] = $userModel->email;
              $user['photourl'] = $userModel->photo;
              $user['client_id'] = $clientID;
          }
  
          $user = json_encode($user);
          $signature_string = base64_encode($user);
          $signature_string = $this->getStr2Hex($signature_string);
          $timestamp = time();
  
          $signature = hash_hmac("sha1", "{$signature_string} {$timestamp}", $secret);
  
          $result = $signature_string." ".$signature." ".$timestamp." hmacsha1";
  
          return $result;
      }
  
  ```
  
  **Tags:** plugin-development, variable
  
  > **Comments:**
  > **username_1**: username_0, would you mind sharing the full plugin you have so far? Running into some strange problems here when trying to make the connection secure.  Regarding the roles, here it mentions just "roles" in the callback; [link](http://blog.vanillaforums.com/jsconnect-technical-documentation/), `"roles": "member,administrator"`  
  > **username_2**: I wrote a simple plugin to handle VanillaForums/jsConnect <-> Craft CMS SSO, if you want to use it: https://github.com/khalwat/Vanillaforums  
  
  ---
  
  ## 0 answers
  
  