title: Phonegap:Login Through LinkedIn Error While Getting Access Token
body: <p>I'm trying to implement Login through LinkedIn using the following link <a href="https://gist.github.com/efc88a38da25ff4e9283" rel="nofollow">Login through LinkedIn</a>
  .</p>
  
  <p>Below is my code`</p>
  
  <pre><code>            var oauth_info = {};
              var consumer_key = "";
             var shared_secret = "";
              var oauth = OAuthSimple(consumer_key, shared_secret);
  
              function parse_response(response) {
                  response.replace(new RegExp("([^?=&amp;]+)(=([^&amp;]*))?", "g"), function($0, $1, $2, $3) { oauth_info[$1] = $3; });
                  console.log("oauth_token1="+oauth_info.oauth_token);
              }
  
              function linkedInLogin()
              {
  
                  var url = oauth.sign({action: "GET", path: "https://api.linkedin.com/uas/oauth/requestToken", parameters: {oauth_callback: "http://www.example.com/"}}).signed_url;
                  console.log("url==="+url);
                  $.ajax(
                         {
                         url:url,
                         data: {},
                         success: function(data){
                         console.log("inside success");
                         console.log("response==="+data);
                         parse_response(data);
                        console.log("oauth_token2="+oauth_info.oauth_token);
                         var params = data;
                          params = params.split('&amp;');
                         for (var i = 0; i &lt; params.length; i++) {
                         var y = params[i].split('=');
                         if(y[0] === 'oauth_token') {
                         localStorage.oauth_token = y[1];
                         console.log("oauth_token=="+localStorage.oauth_token);
                         }
                         if(y[0]==='oauth_token_secret')
                         {
                         localStorage.oauth_token_secret=y[1];
                         console.log("oauth_token_secret=="+localStorage.oauth_token_secret);
                         }
                         }
  
                         step2();
                         },
                         error: function(error) {
                         console.log("error");
                         client_browser.close();
                         },
                         dataType: 'text',
                         type: 'GET'
                         });                    
              }
              function step2()
             {
  
                  var authoriseurl='https://www.linkedin.com/uas/oauth/authenticate?oauth_token='+oauth_info.oauth_token+'';                    
                  window.plugins.childBrowser.showWebPage(authoriseurl);
                  window.plugins.childBrowser.onLocationChange = function(loc){
                      console.log("on loc changed");
                      linkedInChanged(loc);
                  };
  
              }
  
              function linkedInChanged(loc)
              {
                  console.log("inside loc changed");
                 if (loc.indexOf("http://www.example.com/") &gt; -1) { 
                    window.plugins.childBrowser.close(); 
                      console.log("oauth_token3="+oauth_info.oauth_token);
                     var index, verifier = '';            
                     var params = loc.substr(loc.indexOf('?') + 1);
                     params = params.split('&amp;');
                     for (var i = 0; i &lt; params.length; i++) {
                        var y = params[i].split('=');
                         if(y[0] === 'oauth_verifier') {
                             verifier = y[1];
                             console.log("verifier===="+verifier);
                         }
  
                     }
                     var acces_url= access_token_url(verifier);
                     oauth.reset();
                     console.log("oauth_token4="+oauth_info.oauth_token);
                     //console.log("oauth_info"+oauth_info[0][0]+"===="+oauth_info[0][1]);
                     //var url = oauth.sign({action: "GET", path: "https://api.linkedin.com/uas/oauth/accessToken", parameters: {oauth_verifier: verifier}, signatures: oauth_info}).signed_url; 
                     console.log("access _url="+acces_url);
  
                     $.ajax(
                            {
                            url:acces_url,
                            data: {},
                            success: function(data){
                            console.log("inside access token success");
                           console.log("response==="+data);
                            var params = data;
                            params = params.split('&amp;');
                            for (var i = 0; i &lt; params.length; i++) {
                            var y = params[i].split('=');
                            if(y[0] === 'oauth_token') {
                            localStorage.linkedIn_access_Token = y[1];
                            console.log("linkedIn_access_Token=="+localStorage.linkedIn_access_Token);
                            }
                            if(y[0]==='oauth_token_secret')
                            {
                            localStorage.linkedIn_access_secret=y[1];
                            console.log("linkedIn_access_secret=="+localStorage.linkedIn_access_secret);
                            }
                            }
                            },
                           error: function(error){
                            console.log("error=="+error.responseText);
                            },
                            dataType: 'text',
                            type: 'GET'
                            });   
  
  
  
                 }
              }
  
  
              function get_url_vars_from_string(url) {
                  var vars = [], hash;
                  var hashes = url.slice(url.indexOf('?') + 1).split('&amp;');
                  for(var i = 0; i &lt; hashes.length; i++)
                  {
                      hash = hashes[i].split('=');
                      vars.push(hash[0]);
                      vars[hash[0]] = hash[1];
                  }
                  return vars;
  
              }
  
              function access_token_url(pin) {
                  oauth.reset();  
                  //alert(oauth_info.oauth_token);
                  var url = oauth.sign({action: "GET", path: "https://api.linkedin.com/uas/oauth/accessToken", parameters: {oauth_verifier: pin}, signatures: oauth_info}).signed_url;
                 // alert("url="+url);
  
                 return url;
              }
  </code></pre>
  
  <p>`
  On click of a button the linkedInLogin method is called.
  I'm not able to get the access token from this code.The ajax call for access token results in Error oauth_problem=token_rejected</p>
  
  <p>Please help</p>