用户登录接口

  • 接口说明: 用户登录接口
  • 接口地址: /api/login
  • 请求方式: POST

请求参数

参数名称类型是否须描述
usernamestring用户名/手机号
passwordstring密码
tokenstring微信公众号通过code参数换取token接口返回的 token
js_codestring小程序用户名密码登录时传入,会绑定小程序用户信息。
微信小程序登陆code,https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html
ivstring小程序用户名密码登录时传入,会绑定小程序用户信息。
微信小程序用户数据数据加密算法的初始向量,https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html
encryptedDatastring小程序用户名密码登录时传入,会绑定小程序用户信息。
微信小程序用户包括敏感数据在内的完整用户信息的加密数据,https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html

请求示例

  1. {
  2. "data": {
  3. "attributes": {
  4. "username": "username",
  5. "password": "password"
  6. }
  7. }
  8. }

返回结果

参数名称类型出现要求描述
token_typestring登录成功token 类型
expires_inint登录成功时间
access_tokentoken登录成功用户标识
refresh_tokentoken登录成功刷新用户标识

返回说明

  • 登录成功, http 状态码: 200
  • 登录失败, http 状态码: 400

返回示例

  1. {
  2. "data": {
  3. "type": "token",
  4. "id": "1",
  5. "attributes": {
  6. "token_type": "Bearer",
  7. "expires_in": 2592000,
  8. "access_token": "eyJ0eXAiOiJKV1Qi......dj3H9CCSPib6MQtnaT6VNrw",
  9. "refresh_token": "def50200a26b6a9......10ccbf3c1694084c2d2d276"
  10. }
  11. }
  12. }

失败示例

  1. {
  2. "error": "invalid_grant",
  3. "error_description": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",
  4. "hint": "",
  5. "message": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."
  6. }