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

调用Solarman API获取token时持续返回403状态码该如何解决

问题原因及修复方案

核心错误点

  • 请求参数传递位置错误:你当前把所有业务参数放到了params参数中,requests的params是用来传递URL查询参数的,而该接口要求账号、密钥这类核心参数放在POST请求的JSON请求体中,参数位置不匹配会直接导致鉴权失败返回403。
  • 请求头配置错误:accept: application/json是请求头字段,不应该放在请求参数中,需要放到headers参数里配置。
  • 其他可能的校验失败点:确认你使用的appId、appSecret是你在Solarman开放平台申请后拿到的正式参数,账号密码是pro.solarmanpv.com平台的有效登录账号,且账号对应应用的IP白名单已经添加了你当前请求的出口IP。

修正后的代码示例

import requests

# 替换为你自己的实际参数
appid = "你的appId"
appsecret = "你的appSecret"
username = "你的账号"
password = "你的密码"

url = f'https://api.solarmanpv.com/account/v1.0/token?appId={appid}&language=en'

# 正确配置请求头
headers = {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
}

# 正确配置JSON请求体
payload = {
    'appSecret': appsecret,
    'password': password,
    'username': username
}

# POST请求用json参数传递请求体
response = requests.post(url, headers=headers, json=payload)

print(response.status_code)
print(response.json())

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.28 03:36:01