You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Rlinkedin调用LinkedIn API时持续出现连接超时错误求助

Troubleshooting Timeout Errors with Rlinkedin's inOAuth() Function

我之前也碰到过类似的LinkedIn API OAuth超时问题,结合踩过的坑和社区里的解决方案,给你几个可行的排查方向:

  • 检查网络环境与代理设置
    超时最常见的原因就是网络限制,比如公司防火墙、代理或者地区访问限制。你可以试试:

    • 切换到非企业内网(比如手机热点)再运行代码,排除内网防火墙的干扰;
    • 如果必须使用代理,给httr和curl手动配置代理信息(替换成你的代理地址和端口):
      # 配置httr代理
      httr::set_config(httr::use_proxy(url = "your-proxy-address", port = your-proxy-port))
      # 配置curl代理
      curl::handle_setopt(curl::new_handle(), proxy = "your-proxy-address:your-proxy-port")
      

    配置完成后再调用inOAuth()试试。

  • 延长超时时间
    默认的10秒超时阈值可能在网络不稳定时不够用,你可以手动设置更长的超时时间:

    # 给RCurl设置30秒超时
    options(RCurlOptions = list(timeout = 30))
    # 或者给httr单独配置超时
    httr::set_config(httr::config(timeout = 30))
    

    调整后重新走授权流程,看是否能成功连接。

  • 验证LinkedIn应用配置
    再仔细核对一下你的LinkedIn应用设置:

    • 确保OAuth 2.0 Redirect URLs准确设置为http://localhost:1410/,不要有拼写错误(比如多了斜杠、端口号不对);
    • 检查应用状态是否为"Live",虽然开发状态的应用也能走OAuth流程,但部分权限受限可能间接影响连接稳定性。
  • 更新相关依赖包
    旧版本的Rlinkedin、httr或curl可能存在兼容性问题,先更新所有相关包:

    pacman::p_update(rvest, ggplot2, Rlinkedin, httr, curl, devtools, dplyr)
    

    如果Rlinkedin是从GitHub安装的,建议重新安装最新版:

    devtools::install_github("mpiccirilli/Rlinkedin")
    
  • 手动触发OAuth令牌获取
    如果自动授权流程一直卡超时,试试用httr手动发起授权请求:

    1. 从LinkedIn应用后台复制你的Client ID和Client Secret;
    2. 运行以下代码手动获取令牌:
    library(httr)
    # 定义LinkedIn OAuth端点
    auth_endpoint <- oauth_endpoint(
      authorize = "https://www.linkedin.com/oauth/v2/authorization",
      access = "https://www.linkedin.com/oauth/v2/accessToken"
    )
    # 创建应用对象
    linkedin_app <- oauth_app("linkedin", key = "YOUR_CLIENT_ID", secret = "YOUR_CLIENT_SECRET")
    # 获取令牌
    token <- oauth2.0_token(auth_endpoint, linkedin_app, redirect_uri = "http://localhost:1410/", scope = "r_basicprofile")
    

    如果这个手动流程也超时,基本可以确定是网络层面的问题;如果成功,你就可以用这个token代替inOAuth()返回的授权对象来调用LinkedIn API。

内容的提问来源于stack exchange,提问作者Ebrahim Adeeb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:19:25