{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6619c94e",
   "metadata": {},
   "outputs": [],
   "source": [
    "from requests import get,post\n",
    "import time\n",
    "import json\n",
    "ip = \"http://band.hxzhxy.cn\"\n",
    "param = {\n",
    "    \"username\": \"zhongwei\",\n",
    "    \"password\": \"123456a\",\n",
    "    \"client_id\": \"client\",\n",
    "    \"grant_type\": \"password\",\n",
    "    \"client_secret\": \"123456\",\n",
    "}\n",
    "data = get(url=f\"http://band.hxzhxy.cn/oauth/token?username=zhongwei&password=123456a&client_id=client&grant_type=password&client_secret=123456\").json()\n",
    "token = data[\"access_token\"]\n",
    "header = {\n",
    "    \"content-type\": \"application/json\",\n",
    "    \"authorization\": f\"Bearer {token}\",\n",
    "}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "e4f5ed31",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9e6e0e24-67fd-4b7c-802a-b204ff4ca95c\n",
      "{'success': True, 'msg': '操作成功', 'code': 0, 'data': {'id': 475, 'pwd': '{bcrypt}$2a$10$K7EdytUGmdkfGn.zvLlg3O62TV5hCptj83MGbweHK0jSw8kzZPZ2m', 'locked': False, 'enabled': True, 'role': {'id': 168, 'roleName': '鸿兴演示中学家长', 'description': None, 'priority': 10, 'createTime': 1622713421000, 'updateTime': 1659193585000, 'teamId': 106, 'type': 1}, 'teamId': 106, 'type': 3, 'authorities': [{'authority': '鸿兴演示中学家长'}], 'username': 'jz97621', 'password': '{bcrypt}$2a$10$K7EdytUGmdkfGn.zvLlg3O62TV5hCptj83MGbweHK0jSw8kzZPZ2m', 'accountNonExpired': True, 'accountNonLocked': True, 'credentialsNonExpired': True}}\n"
     ]
    }
   ],
   "source": [
    "param={\n",
    "    \"username\": 17307283669,\n",
    "    \"password\": \"jz97621\",\n",
    "    \"client_id\": \"client\",\n",
    "    \"grant_type\": \"password\",\n",
    "    \"client_secret\": \"123456\",\n",
    "    \"login_type\": \"PHONE_USERNAME\"\n",
    "}\n",
    "token = get(\"https://band.hxzhxy.cn/oauth/token\",params=param).json()[\"access_token\"]\n",
    "print(token)\n",
    "data = get(f\"https://band.hxzhxy.cn/uc/account/current?access_token={token}\").json()\n",
    "print(data)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "b9c253b1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fab765b1-46f0-4e2a-816b-ebdeb9d31cdf\n"
     ]
    }
   ],
   "source": [
    "access_token=get(\"https://band.hxzhxy.cn/oauth/token?username=17307283669&password=2019240217HXYSZX&client_id=client&grant_type=password&client_secret=123456&login_type=PHONE_USERNAME\").json()[\"access_token\"]\n",
    "print(access_token)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "9136ed38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'success': True,\n",
       " 'msg': '操作成功',\n",
       " 'code': 0,\n",
       " 'data': {'id': 5454,\n",
       "  'pwd': '{bcrypt}$2a$10$I66PBUWdeoWYh/FcGfhB1O2T1a8NJOpFB8YVZtScmH3YO7tNzuSBm',\n",
       "  'locked': False,\n",
       "  'enabled': True,\n",
       "  'role': {'id': 168,\n",
       "   'roleName': '鸿兴演示中学家长',\n",
       "   'description': None,\n",
       "   'priority': 10,\n",
       "   'createTime': 1622713421000,\n",
       "   'updateTime': 1659193585000,\n",
       "   'teamId': 106,\n",
       "   'type': 1},\n",
       "  'teamId': 106,\n",
       "  'type': 3,\n",
       "  'authorities': [{'authority': '鸿兴演示中学家长'}],\n",
       "  'username': '2019240217HXYSZX',\n",
       "  'password': '{bcrypt}$2a$10$I66PBUWdeoWYh/FcGfhB1O2T1a8NJOpFB8YVZtScmH3YO7tNzuSBm',\n",
       "  'accountNonExpired': True,\n",
       "  'accountNonLocked': True,\n",
       "  'credentialsNonExpired': True}}"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get(f\"https://band.hxzhxy.cn/uc/account/current?access_token={access_token}\").json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ffcb6b87",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'success': False, 'msg': '非法访问,没有认证', 'code': 10007, 'data': None}"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
