Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
9a3d97f1
Unverified
Commit
9a3d97f1
authored
Sep 08, 2018
by
老广
Committed by
GitHub
Sep 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1798 from CaoZhenggg/patch-5
Update user_api.rst
parents
4b0316e2
b745073c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
1 deletion
+36
-1
user_api.rst
docs/user_api.rst
+36
-1
No files found.
docs/user_api.rst
View file @
9a3d97f1
...
@@ -7,8 +7,8 @@ API 文档
...
@@ -7,8 +7,8 @@ API 文档
# ( 如 http://192.168.244.144/docs )
# ( 如 http://192.168.244.144/docs )
# 注:需要打开 debug 模式,jumpserver/config.py Debug=True
# 注:需要打开 debug 模式,jumpserver/config.py Debug=True
手动调用 api 的方法
- 手动调用 api 的方法
::
::
$ curl -X POST -H 'Content-Type: application/json' -d '{"username": "admin", "password": "admin"}' http://localhost/api/users/v1/token/ # 获取token
$ curl -X POST -H 'Content-Type: application/json' -d '{"username": "admin", "password": "admin"}' http://localhost/api/users/v1/token/ # 获取token
...
@@ -16,3 +16,38 @@ API 文档
...
@@ -16,3 +16,38 @@ API 文档
$ curl -H 'Authorization: Bearer 937b38011acf499eb474e2fecb424ab3' -H "Content-Type:application/json" http://localhost/api/users/v1/users/
$ curl -H 'Authorization: Bearer 937b38011acf499eb474e2fecb424ab3' -H "Content-Type:application/json" http://localhost/api/users/v1/users/
# 使用token访问,token有效期 1小时
# 使用token访问,token有效期 1小时
- python代码示例
::
import requests
import json
from pprint import pprint
def get_token():
url = 'https://jumpserver.tk/api/users/v1/token/'
query_args = {
"username": "admin",
"password": "admin"
}
response = requests.post(url, data=query_args)
return json.loads(response.text)['Token']
def get_user_info():
url = 'https://jumpserver.tk/api/users/v1/users/'
token = get_token()
header_info = { "Authorization": 'Bearer ' + token }
response = requests.get(url, headers=header_info)
pprint(json.loads(response.text))
get_user_info()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment