dongpu1881 2015-07-15 09:37
浏览 182

curl获取Linkedin Access Token时出错

I need to show my company updates from Linkedin so I have created a Linkedin APP. I need to authenticate with OAuth2 in Linkedin with my app, not the user who visit my site.

I'm trying to get the acces token with curl, but I get always this error:

string(153) "{"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : client_id","error":"invalid_request"}"

My code is:

$code = isset($_REQUEST['code'])?$_REQUEST['code']:"";                

        $curl_request = curl_init();
        curl_setopt_array($curl_request, array(
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL => "https://www.linkedin.com/uas/oauth2/accessToken",
            CURLOPT_POST => 1,
            CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded'),
            CURLOPT_POSTFIELDS => array(
                grant_type => "authorization_code",
                code => $code,
                redirect_uri => LINKEDIN_CALLBACK_URL,
                client_id => LINKEDIN_API_KEY,
                client_secret =>  LINKEDIN_API_SECRETE_KEY
            )
        ));

        $curl_result = curl_exec($curl_request);

        var_dump($curl_result);
  • 写回答

1条回答 默认 最新

  • dongou0524 2015-07-24 19:16
    关注

    LinkedIn's OAuth 2.0 implementation does not currently support two-legged authentication. You will have to authenticate with a particular member - whether it's the currently active user, or your own account that you authenticate one-time and then silently keep reusing that access token for and renewing it ever 60 days to prevent it from expiring.

    That said, your error seems related to the fact that you are not properly formulating the request to get an accessToken from LinkedIn because the client_id parameter is not being recognized. Walk through the OAuth 2.0 documentation to ensure you're formatting your HTTP requests properly throughout the authentication process: https://developer.linkedin.com/docs/oauth2

    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图