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

未修改代码情况下Spotify Authorization Code Flow突然失效求助

Spotify授权码流程请求超时问题

我有一个自今年1月起正常运行的WordPress插件,用于在网页上显示我Spotify账户当前播放歌曲的标题和作者。但几天前它突然停止工作,原因是Authorization Code Flow无法完成:通过"authorize"端点获取授权码的第一步正常,但回调尝试用收到的授权码向"token"端点发送HTTP POST请求时超时。

参数准备代码

$state = $_GET['state'];  /* this is a verified nonce */
$code = $_GET['code'];    /* this is the auth code received from "authorize" */
$client_id = get_option($this->client_id_option);
$client_secret = get_option($this->client_secret_option);
$redirect_uri = admin_url('options-general.php?page=spotify-token-manager');

向token端点发送请求的代码

$response = wp_remote_post('https://accounts.spotify.com/api/token', [
    'headers' => [
        'Authorization' => 'Basic ' . base64_encode($client_id . ':' . $client_secret),
        'Content-Type' => 'application/x-www-form-urlencoded'
    ],
    'body' => [
        'grant_type' => 'authorization_code',
        'code' => $code,
        'redirect_uri' => $redirect_uri,
        'state' => $state
    ]
]);

返回的错误信息

{"errors":{"http_request_failed":["cURL error 28: Connection timed out after 5001 milliseconds"]},"error_data":[]}

另外,在命令行中使用相同参数执行curl命令,能正常获取token及刷新token。代码未做修改却出现此问题,目前无法理解原因。

编辑
目前判断是基础设施相关问题,而非代码问题,比如IPv6、DNS、负载均衡器、内容过滤器等。待ISP给出答复后会更新相关信息。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 00:22:47