请注意:同样方式获取的Token有60天有效期,请妥善存储Token,勿泄露,勿频繁重复获取
Home
!不带 orgID 时,只能访问登录https://home.solarmanpv.com/后看到的数据
Pro
!带 orgID 时,只能访问登录https://pro.solarmanpv.com/后看到的数据
获取Token共有三种方式,对应到Solarman平台的三种登录方式
- 邮箱登录
- 必填email
- 手机号登录
- 必填countryCode
- 必填mobile
- 用户名登录
- 必填username
| 获取token | | | | |
| —- | —- | —- | —- | —- |
| 接口描述 | Token是调用资源的凭据,目前支持注册账号的手机号、电子邮箱、用户名,三选一登录(mobile,email,username字段 三选一必传,当传mobile字段时countryCode字段必传),orgId 不传时获取到的是C端用户Token, 当orgId传值时获取到的是对应商家的Token. | | | |
| 请求URL | https://api.solarmanpv.com/account/v1.0/token | | | |
| 请求方式 | post | | | |
| 请求类型 | application/json | | | |
| 返回类型 | / | | | |
| 请求参数 | | | | |
| 参数名 | 数据类型 | 参数类型 | 是否必填 | 描述说明 |
| appId | string | query | Y | 应用APPID 示例值:201911067156002 |
| appSecret | string | body | Y | appSecret密钥 ,示例值:1q3e2ee5w5w20ww |
| countryCode | string | body | N | 国家代码 ,示例值:86 |
| email | string | body | N | 邮箱号 ,示例值:13255@qq.com |
| mobile | string | body | N | 手机号 ,示例值:13255200000 |
| orgId | integer | body | N | 商家ID ,示例值:12
通过2.2接口的companyId字段获取 | | password | string | body | Y | 密码(sha256加密)
示例
原文:
solarman123
sha256:
b6fb8971000faab81a3d6c6f4739f1240055d04af96816d68c9f7d89d1691918
请原文小写输出sha256后的密码
| | username | string | body | N | 用户名 ,示例值:sunsun | | 响应参数 | | | | | | 参数名 | 数据类型 | 参数类型 | 是否必填 | 描述说明 | | access_token | string | body | N | access_token ,示例值:eyJhbGciOiJSUzI1NiIsInR5cC | | code | string | body | N | 信息码 ,示例值:10000 | | expires_in | string | body | N | expires_in ,示例值:5183999(单位秒) | | refresh_token | string | body | N | refresh_token ,示例值:eyJhbGciOiJSUzI1NiIsInR5cC | | scope | string | body | N | scope ,示例值:all | | token_type | string | body | N | token_type ,示例值:bearer | | uid | integer | body | N | 用户ID ,示例值:all | | msg | string | body | N | 信息描述 ,示例值:success | | success | boolean | body | N | 是否成功 ,示例值:true | | requestId | string | body | N | 请求标识 ,示例值:1d6f6eca9bee4b6483d4af064b659eec | | 示例 | | | | | | 请求参数 | /account/v1.0/token?appId=201911067232002&language=en
{
“appSecret”: “3a8791f012acc13226ca60e63ac6c1aff3”,
“username”: “cvwwb”,
“orgId”: 860,
“password”: “472bbe83616e93d3c09a79103ae47d8f71e3d35a966d6e8b22f743218d04171d”
} | | | | | 返回值 | {
“code”: null,
“msg”: null,
“success”: true,
“requestId”: “9d8cfe698b344d2780478006462899de”,
“access_token”: “eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiI4NjBfY3ZiXzMiLCJzY29wZSI6WyJhuu9IH6DXL_ZOx5RHvts8K9a_k1eEA7wadIB32we9o0zTJgbzC1oGyB1FqbQ”,
“token_type”: “bearer”,
“refresh_token”: “eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiI4NjBfY3ZiXzMiLCJzY29wZSI6WyJhbGwiXSwiYXRpIjoiZGYxYjlmODQtMzhiNC00ZTEzLWIxYTktZjE3ZWZhMjMjJ7FW59UavQ4uw-651xNcoxpj754eMrPP3SVO9_HI4aufGsIP1P7PPWzJ3VZsckTLHas6cWWEvdengunK2BLLsokdz4klxsT3oX0BmewfcWEZ9qjGenF0Ht0eRLZdaRwr2skqHhUQ”,
“expires_in”: “5183999”,
“scope”: null,
“uid”: 6681
} | | | |
- 必填username
| 获取token | | | | |
| —- | —- | —- | —- | —- |
| 接口描述 | Token是调用资源的凭据,目前支持注册账号的手机号、电子邮箱、用户名,三选一登录(mobile,email,username字段 三选一必传,当传mobile字段时countryCode字段必传),orgId 不传时获取到的是C端用户Token, 当orgId传值时获取到的是对应商家的Token. | | | |
| 请求URL | https://api.solarmanpv.com/account/v1.0/token | | | |
| 请求方式 | post | | | |
| 请求类型 | application/json | | | |
| 返回类型 | / | | | |
| 请求参数 | | | | |
| 参数名 | 数据类型 | 参数类型 | 是否必填 | 描述说明 |
| appId | string | query | Y | 应用APPID 示例值:201911067156002 |
| appSecret | string | body | Y | appSecret密钥 ,示例值:1q3e2ee5w5w20ww |
| countryCode | string | body | N | 国家代码 ,示例值:86 |
| email | string | body | N | 邮箱号 ,示例值:13255@qq.com |
| mobile | string | body | N | 手机号 ,示例值:13255200000 |
| orgId | integer | body | N | 商家ID ,示例值:12
示例
python
手机号登录
# Install the Python Requests library:
# `pip install requests`
import requests
import json
def send_request():
# 2.1 Obtain Token for B END-MP
# POST https://api.solarmanpv.com/account/v1.0/token
try:
response = requests.post(
url="https://api.solarmanpv.com/account/v1.0/token",
params={
"appId": "appId",
"language": "zh",
},
headers={
"Content-Type": "application/json",
"User-Agent":"Paw/3.3.1 (Macintosh; OS X/12.0.1) GCDHTTPRequest"
},
data=json.dumps({
"countryCode": "86",
"orgId": orgId,
"mobile": "",
"password": "password",
"appSecret": "appSecret"
})
)
print('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code))
print('Response HTTP Response Body: {content}'.format(
content=response.content))
except requests.exceptions.RequestException:
print('HTTP Request failed')
邮箱登录
# Install the Python Requests library:
# `pip install requests`
import requests
import json
def send_request():
# 2.1 Obtain Token for B END-EP
# POST https://api.solarmanpv.com/account/v1.0/token
try:
response = requests.post(
url="https://api.solarmanpv.com/account/v1.0/token",
params={
"appId": "appId",
"language": "en",
},
headers={
"Content-Type": "application/json",
"User-Agent":"Paw/3.3.1 (Macintosh; OS X/12.0.1) GCDHTTPRequest"
},
data=json.dumps({
"email": "email",
"password": "password",
"orgId": orgId,
"appSecret": "appSecret"
})
)
print('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code))
print('Response HTTP Response Body: {content}'.format(
content=response.content))
except requests.exceptions.RequestException:
print('HTTP Request failed')
用户名登录
# Install the Python Requests library:
# `pip install requests`
import requests
import json
def send_request():
# 2.1 Obtain Token for B END-AP
# POST https://api.solarmanpv.com/account/v1.0/token
try:
response = requests.post(
url="https://api.solarmanpv.com/account/v1.0/token",
params={
"appId": "appId",
"language": "zh",
},
headers={
"Content-Type": "application/json",
"User-Agent":"Paw/3.3.1 (Macintosh; OS X/12.0.1) GCDHTTPRequest"
},
data=json.dumps({
"password": "password",
"orgId": "orgId",
"appSecret": "appSecret"
})
)
print('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code))
print('Response HTTP Response Body: {content}'.format(
content=response.content))
except requests.exceptions.RequestException:
print('HTTP Request failed')