Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lichenggang
/
tas_token_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c8b665d7
authored
Mar 25, 2021
by
lichenggang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
请求自动登录digikey同步token接口
parent
ace1d9ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
lib/apidigikey.py
lib/apidigikey.py
View file @
c8b665d7
...
...
@@ -41,13 +41,21 @@ class DGTokenCrawler(token_lib.BaseTokenCrawler):
self
.
redirect_uri
=
'https://bigdata.ichunt.com/digikey_auth.php'
self
.
_pool
=
redis
.
ConnectionPool
(
host
=
apidigikey_ip
,
port
=
6379
,
db
=
0
,
password
=
psd
)
self
.
_redis
=
redis
.
Redis
(
connection_pool
=
self
.
_pool
)
self
.
refresh_token_url
=
"127.0.0.1:8721/refresh"
def
get_params_list
(
self
):
return
[[
i
]
for
i
in
range
(
THREAD_NUM
)]
def
collect_token
(
self
):
try
:
access_token
,
refresh_token
=
self
.
get_token_by_refresh_token
()
token_json
=
self
.
get_token_by_refresh_token
()
if
not
token_json
.
get
(
'access_token'
,
''
):
dd_send_msg
(
'digikey自动登录同步token'
)
resp
=
requests
.
get
(
self
.
refresh_token_url
,
timeout
=
(
10
,
30
))
.
json
()
if
resp
[
'status'
]
==
500
:
raise
Exception
(
resp
[
'msg'
])
token_json
=
resp
[
'data'
]
access_token
,
refresh_token
=
token_json
[
'access_token'
],
token_json
[
'refresh_token'
]
apidigikey_log
.
info
(
access_token
)
apidigikey_log
.
info
(
refresh_token
)
return
access_token
,
refresh_token
...
...
@@ -83,7 +91,8 @@ class DGTokenCrawler(token_lib.BaseTokenCrawler):
}
resp
=
requests
.
post
(
p_url
,
headers
=
p_headers
,
data
=
p_data
,
timeout
=
(
15
,
20
))
token_json
=
resp
.
json
()
return
token_json
[
'access_token'
],
token_json
[
'refresh_token'
]
return
token_json
def
process
(
self
,
is_main
):
access_token
,
refresh_token
=
self
.
collect_token
()
...
...
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