请注意:同样方式获取的Token有60天有效期,请妥善存储Token,勿泄露,勿频繁重复获取

Home

!不带 orgID 时,只能访问登录https://home.solarmanpv.com/后看到的数据

Pro

!带 orgID 时,只能访问登录https://pro.solarmanpv.com/后看到的数据

获取Token共有三种方式,对应到Solarman平台的三种登录方式

  1. 邮箱登录
    1. 必填email
  2. 手机号登录
    1. 必填countryCode
    2. 必填mobile
  3. 用户名登录
    1. 必填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
      } | | | |

示例

python

手机号登录

  1. # Install the Python Requests library:
  2. # `pip install requests`
  3. import requests
  4. import json
  5. def send_request():
  6. # 2.1 Obtain Token for B END-MP
  7. # POST https://api.solarmanpv.com/account/v1.0/token
  8. try:
  9. response = requests.post(
  10. url="https://api.solarmanpv.com/account/v1.0/token",
  11. params={
  12. "appId": "appId",
  13. "language": "zh",
  14. },
  15. headers={
  16. "Content-Type": "application/json",
  17. "User-Agent":"Paw/3.3.1 (Macintosh; OS X/12.0.1) GCDHTTPRequest"
  18. },
  19. data=json.dumps({
  20. "countryCode": "86",
  21. "orgId": orgId,
  22. "mobile": "",
  23. "password": "password",
  24. "appSecret": "appSecret"
  25. })
  26. )
  27. print('Response HTTP Status Code: {status_code}'.format(
  28. status_code=response.status_code))
  29. print('Response HTTP Response Body: {content}'.format(
  30. content=response.content))
  31. except requests.exceptions.RequestException:
  32. print('HTTP Request failed')

邮箱登录

  1. # Install the Python Requests library:
  2. # `pip install requests`
  3. import requests
  4. import json
  5. def send_request():
  6. # 2.1 Obtain Token for B END-EP
  7. # POST https://api.solarmanpv.com/account/v1.0/token
  8. try:
  9. response = requests.post(
  10. url="https://api.solarmanpv.com/account/v1.0/token",
  11. params={
  12. "appId": "appId",
  13. "language": "en",
  14. },
  15. headers={
  16. "Content-Type": "application/json",
  17. "User-Agent":"Paw/3.3.1 (Macintosh; OS X/12.0.1) GCDHTTPRequest"
  18. },
  19. data=json.dumps({
  20. "email": "email",
  21. "password": "password",
  22. "orgId": orgId,
  23. "appSecret": "appSecret"
  24. })
  25. )
  26. print('Response HTTP Status Code: {status_code}'.format(
  27. status_code=response.status_code))
  28. print('Response HTTP Response Body: {content}'.format(
  29. content=response.content))
  30. except requests.exceptions.RequestException:
  31. print('HTTP Request failed')

用户名登录

  1. # Install the Python Requests library:
  2. # `pip install requests`
  3. import requests
  4. import json
  5. def send_request():
  6. # 2.1 Obtain Token for B END-AP
  7. # POST https://api.solarmanpv.com/account/v1.0/token
  8. try:
  9. response = requests.post(
  10. url="https://api.solarmanpv.com/account/v1.0/token",
  11. params={
  12. "appId": "appId",
  13. "language": "zh",
  14. },
  15. headers={
  16. "Content-Type": "application/json",
  17. "User-Agent":"Paw/3.3.1 (Macintosh; OS X/12.0.1) GCDHTTPRequest"
  18. },
  19. data=json.dumps({
  20. "password": "password",
  21. "orgId": "orgId",
  22. "appSecret": "appSecret"
  23. })
  24. )
  25. print('Response HTTP Status Code: {status_code}'.format(
  26. status_code=response.status_code))
  27. print('Response HTTP Response Body: {content}'.format(
  28. content=response.content))
  29. except requests.exceptions.RequestException:
  30. print('HTTP Request failed')