Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
bedc2671
authored
2022-03-29 11:14:46 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
da0c926a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
src/apps/account/views.py
src/common/mixins.py
src/apps/account/views.py
View file @
bedc267
...
...
@@ -52,8 +52,8 @@ class IWALoginView(IWABaseView, GenericView):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
code
=
request
.
data
.
get
(
'code'
,
''
)
redirect_uri
=
request
.
data
.
get
(
'redirect_uri'
,
''
)
q_number
=
self
.
get_q_number
(
conf
.
IWA_URL
,
code
,
redirect_uri
,
client_id_base64
)
#
redirect_uri = request.data.get('redirect_uri', '')
q_number
=
self
.
get_q_number
(
conf
.
IWA_URL
,
code
,
conf
.
IWA_REDIRECT_URI
,
client_id_base64
)
is_valid
,
data
=
self
.
validate
(
q_number
)
...
...
src/common/mixins.py
View file @
bedc267
...
...
@@ -113,24 +113,24 @@ class IWABaseView:
@staticmethod
def
get_token
(
iwa_url_base
,
code
,
redirect_uri
,
client_id_base64
):
headers
=
{
'
a
uthorization'
:
'Basic {0}'
.
format
(
client_id_base64
),
# client_id:secret做base64encode
'
c
ontent-type'
:
'application/x-www-form-urlencoded'
,
'
A
uthorization'
:
'Basic {0}'
.
format
(
client_id_base64
),
# client_id:secret做base64encode
'
C
ontent-type'
:
'application/x-www-form-urlencoded'
,
}
get_params_dict
=
{
'grant_type'
:
'authorization_code'
,
'code'
:
code
,
'redirect_uri'
:
redirect_uri
,
}
get_params_str
=
'&'
.
join
([
'{0}={1}'
.
format
(
k
,
v
)
for
k
,
v
in
get_params_dict
.
items
()])
iwa_token_url
=
'{0}access_token
?{1}'
.
format
(
iwa_url_base
,
get_params_str
)
res
=
requests
.
post
(
iwa_token_url
,
headers
=
headers
)
#
get_params_str = '&'.join(['{0}={1}'.format(k, v) for k, v in get_params_dict.items()])
iwa_token_url
=
'{0}access_token
'
.
format
(
iwa_url_base
)
res
=
requests
.
post
(
url
=
iwa_token_url
,
headers
=
headers
,
data
=
get_params_dict
)
return
res
.
json
()
.
get
(
'access_token'
,
''
)
def
get_q_number
(
self
,
iwa_url_base
,
code
,
redirect_uri
,
client_id_base64
):
access_token
=
self
.
get_token
(
iwa_url_base
,
code
,
redirect_uri
,
client_id_base64
)
headers
=
{
'
a
uthorization'
,
'Bearer {0}'
.
format
(
access_token
)
'
A
uthorization'
,
'Bearer {0}'
.
format
(
access_token
)
}
iwa_user_url
=
'{0}userinfo'
.
format
(
iwa_url_base
)
res
=
requests
.
get
(
iwa_user_url
,
headers
=
headers
)
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment