调用Allegro API按分类ID获取商品列表遇403权限问题求助
问题重现
已成功获取Bearer Token,且能正常调用接口获取分类及其ID,但调用offers/listing接口时返回403错误:
$response = $client->request( 'GET', 'https://api.allegro.pl/offers/listing', [ 'headers' => [ 'Authorization' => 'Bearer '.$token, 'Content-Type' => 'application/vnd.allegro.public.v1+json' ], ] );
错误响应:
Exception: Client error:
GET https://api.allegro.pl/offers/listingresulted in a403 Forbiddenresponse: {"errors":[{"code":"VerificationRequired","message":"Access is denied. Verification is required.","details":null,"path": (truncated...)
可能的解决步骤
检查Token的权限范围(Scopes)
获取Token时必须请求offers:read权限,若仅申请了分类相关权限(如categories:read),则无法访问商品列表接口。去Allegro开发者后台确认应用已添加该权限,重新生成Token测试。完成账号验证
错误提示明确要求验证,大概率是你的Allegro卖家账号未完成身份验证或店铺资质审核。登录Allegro卖家后台,查看是否有待处理的验证任务,完成后再重试接口调用。补充必要的请求参数
offers/listing接口需要至少一个筛选条件(比如分类ID),示例代码中未携带任何查询参数,可能触发权限拦截。尝试在URL中添加分类ID参数:$response = $client->request('GET', 'https://api.allegro.pl/offers/listing?category.id=你的分类ID', [ 'headers' => [ 'Authorization' => 'Bearer '.$token, 'Content-Type' => 'application/vnd.allegro.public.v1+json' ], ]);确认API版本兼容性
检查Content-Type指定的版本是否匹配接口要求。若v1版本不再维护,可尝试更换为application/vnd.allegro.public.v2+json。
内容的提问来源于stack exchange,提问作者Platon

