dsgdg54ef4365 2013-02-04 03:19 采纳率: 0%
浏览 448

LinkedIN:阻止自动登录而不要求允许访问(JavaScript)

In my appliaction I have used linkedIn API to login. If the user is already loggedIn in the linkedIn in same browser and pressing linkedin login button in my website , the user will automatically loggedin to my website. But i want to ask 'Allow Access' popup authentication window provided by linkedIn.

EDIT : using Samer Bechara answer

$(document).ajaxSend(function(event, jqxhr, settings) {   
    if ( settings.url == "https://www.linkedin.com/uas/oauth/authenticate" ) {
           settings.url = "https://www.linkedin.com/uas/oauth/authorize"   
    } 


 });

<script type="text/javascript" src="http://platform.linkedin.com/in.js">
        api_key: apikey goes here
        onLoad: onLinkedInLoad
      authorize: false
    </script>

    <script type="text/javascript">
      function onLinkedInLoad() {
       IN.ENV.js.scope = new Array();
       IN.ENV.js.scope[0] = "r_emailaddress";
       IN.ENV.js.scope[1] = "r_contactinfo";  

       //IN.User.authorize();
       IN.Event.on(IN, "auth", onLinkedInAuth);
      }




      function onLinkedInAuth() {

        IN.API.Profile("me").fields("id,firstName,lastName,headline,emailAddress,mainAddress,phoneNumbers").result(displayProfiles);
      }

      function displayProfiles(profiles) {

        member = profiles.values[0];
        var phs="";
        var mid =member.id;
        var eid= member.emailAddress;
        var mad= member.mainAddress;
        var ln= member.lastName;
        var fn= member.firstName;
         var json = JSON.stringify(profiles);
         var ph=member.phoneNumbers._total;

         if(ph >0){
          phs=member.phoneNumbers.values[0].phoneNumber;
         }


      }

    </script>
  • 写回答

1条回答

  • douxi5940 2013-02-04 13:31
    关注

    In order to achieve what you want, you should change your OAuth endpoint from https://www.linkedin.com/uas/oauth/authenticate to https://www.linkedin.com/uas/oauth/authorize. This should work for you.

    However, this cannot be done using the Javascript-based API, because their JS file is obsfucated, for security purposes. The only way to do so is to move your authentication system to the server side (e.g. PHP), which allows you to change the authorization endpoint yourself.

    Edit

    You can use the jQuery.ajaXSend() method as follows to modify the request. I haven't tested this, but should work for you.

    $(document).ajaxSend(function(event, jqxhr, settings) {   
        if ( settings.url == "https://www.linkedin.com/uas/oauth/authenticate" ) {
               settings.url = "https://www.linkedin.com/uas/oauth/authorize"   
        } 
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?