{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "39b16c44", "metadata": {}, "outputs": [], "source": [ "from requests import get,post\n", "import time\n", "ip = \"http://192.168.0.209:8100\"\n", "param = {\n", " \"username\": \"tangchao\",\n", " \"password\": \"123456a\",\n", " \"client_id\": \"client\",\n", " \"grant_type\": \"password\",\n", " \"client_secret\": \"123456\",\n", "}\n", "data = get(url=f\"{ip}/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", "}" ] }, { "cell_type": "code", "execution_count": 16, "id": "9f7ca2db", "metadata": {}, "outputs": [], "source": [ "access_token = post(\"https://szihj.idsp.yunxiao.com/Open/Access/GetToken\",params={\n", " \"corpId\": \"869376250979578017\",\n", " \"corpSecret\": \"GQSYGTLMKNJHVLHZMHYDMHATIGTTOBYP\"\n", " }).json()\n" ] }, { "cell_type": "code", "execution_count": 18, "id": "83ed8c86", "metadata": {}, "outputs": [], "source": [ "token= access_token[\"access_token\"]" ] }, { "cell_type": "code", "execution_count": null, "id": "0463e46a", "metadata": {}, "outputs": [], "source": [ "HttpHeaders httpHeaders = new HttpHeaders();\n", " HttpEntity httpEntity = new HttpEntity(null, httpHeaders);\n", " String url = synchronizationStudentOpenByTeamIdAndType.getAddress() + \"?corpId=\" + synchronizationStudentToken.getCorpId() + \"&corpSecret=\" + synchronizationStudentToken.getCorpSecret();\n", " RestTemplate restTemplateHttps = new RestTemplate(RestTemplateConfig.getHttpComponentsClientHttpRequestFactory());\n", " ResponseEntity results = restTemplateHttps.exchange(url, HttpMethod.POST, httpEntity, String.class);\n", " JSONObject json = JSON.parseObject(results.getBody());\n", " System.out.println(\"access_token-----json-----:\"+json);" ] }, { "cell_type": "code", "execution_count": 19, "id": "98f9d828", "metadata": {}, "outputs": [], "source": [ "header={\n", " \"Authorization\": token\n", "}" ] }, { "cell_type": "code", "execution_count": 21, "id": "bc1d9df5", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'{\"errcode\":0,\"errmsg\":\"ok\",\"data\":[]}'" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "get(\"https://szihj.idsp.yunxiao.com/Open/Leave/GetLeaveList\",headers=header).text\n" ] } ], "metadata": { "kernelspec": { "display_name": "base", "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 }