title: Facebook Registration Plugin getting registration data from signed_request using Javascript SDK
body: <p>I am trying to use registration plugin of facebook using javascript SDK. As far as I know following are the steps in order to get the registration data:</p>
  
  <p>1) Show the registration block (prefill the information if consumer is logged in to facebook)
  2) Consumer fills all the information and clicks on register.
  3) We get the signed request from facebook which is encrypted.
  4) Decode the signed_request to get the "Code".
  5) Verify if this code is the correct.
  6) Using this code,get access token
  7) Using the access token we can get consumer data like name, email, gender, etc.</p>
  
  <p>I can get my code working till step 4.</p>
  
  <p>a) After that I would like to know how to verify the "Code" 
  b) For now I skipped that step 5 and when I am trying to get the "Access Token" using "Code" I get error-191 : Redirect URI must be an absolute URI.</p>
  
  <p>Here is my code, kindly guide me in resolving this:</p>
  
  <pre><code>&lt;script&gt;
            window.fbAsyncInit = function() {
          FB.init({
              appId      : 'xxx', // App ID
              channelUrl : 'http:// localhost.qualityhealth.com/channel.html', 
              status     : true, // check login status
              cookie     : true, // enable cookies to allow the server to access the session
              xfbml      : true,  // parse XFBML
              oauth      : true
          });
  
          // Additional initialization code such as adding Event Listeners goes here
          FB.getLoginStatus(function(response) {
              if (response.status === 'connected') {
  
                  var signedRequest = response.authResponse.signedRequest;
                  var verifier = parse_signed_request(signedRequest, 'CLIENT_SECRET');
                  var code = verifier.code;
  
                  FB.api('https://graph.facebook.com/oauth/access_token?   client_id=CLIENT_ID&amp;client_secret=CLIENT_SECRET&amp;redirect_uri=http://localhost.qualityhealth.com&amp;code=' + code, function(response1) {
                      console.log(response1);
  
                  });
              }
          });
  
      };
      // Load the SDK Asynchronously
      (function(d){
          var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement('script'); js.id = id; js.async = true;
          js.src = "//connect.facebook.net/en_US/all.js";
          ref.parentNode.insertBefore(js, ref);
      }(document));
  
  
      function parse_signed_request(signed_request, secret) {
  
          encoded_data = signed_request.split('.',2);
          // decode the data
          sig = encoded_data[0];
          json = decode64(encoded_data[1]);
          data = JSON.parse(json); 
  
          // check algorithm - not relevant to error
          if (!data.algorithm || data.algorithm.toUpperCase() != 'HMAC-SHA256') {
              console.error('Unknown algorithm. Expected HMAC-SHA256');
              return null;
          }
  
          // check sig - not relevant to error
  
          console.log(data);
          return data;
      }
  
      function decode64(s) {
          var e={},i,b=0,c,x,l=0,a,r='',w=String.fromCharCode,L=s.length;
          var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
          for(i=0;i&lt;64;i++){e[A.charAt(i)]=i;}
          for(x=0;x&lt;L;x++){
              c=e[s.charAt(x)];b=(b&lt;&lt;6)+c;l+=6;
              while(l&gt;=8){((a=(b&gt;&gt;&gt;(l-=8))&amp;0xff)||(x&lt;(L-2)))&amp;&amp;(r+=w(a));}
          }
          return r;
      };
  
  &lt;/script&gt;
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  
  &lt;!--- Output Facebook Box---&gt;
  &lt;fb:registration redirect-uri="http://localhost.qualityhealth.com"
                   fields='[
          {"name":"name"},
          {"name":"first_name"},
          {"name":"email"},
          {"name":"state", "description":"State", "type":"text"},
          {"name":"gender"},
          {"name":"phone",      "description":"Phone Number", "type":"text"},
          {"name":"birthday"}
          ]'
          &gt;
  &lt;/fb:registration&gt;
  </code></pre>
  
  <p>Thanks in advance for help.</p>