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 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办