FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
code-examples-python/app/admin/utils.py at master · bliotti/code-examples-python · GitHub
bliotti
/
code-examples-python
Public
forked from
docusign/code-examples-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
code-examples-python
/
app
/
admin
/
utils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
47 lines (36 loc) · 1.43 KB
Breadcrumbs
code-examples-python
/
app
/
admin
/
utils.py
Copy path
File metadata and controls
47 lines (36 loc) · 1.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from
docusign_admin
import
ApiClient
,
AccountsApi
,
UsersApi
from
flask
import
session
from
app
.
ds_config
import
DS_CONFIG
def
create_admin_api_client
(
access_token
):
"""Create API client and construct API headers"""
# return api_client
api_client
=
ApiClient
(
host
=
DS_CONFIG
[
"admin_api_client_host"
],
header_name
=
"Authorization"
,
header_value
=
f"Bearer
{
access_token
}
"
)
return
api_client
def
get_organization_id
():
account_id
=
session
[
"ds_account_id"
]
access_token
=
session
[
"ds_access_token"
]
api_client
=
ApiClient
(
host
=
DS_CONFIG
[
"admin_api_client_host"
])
api_client
.
set_default_header
(
header_name
=
"Authorization"
,
header_value
=
f"Bearer
{
access_token
}
"
)
accounts_api
=
AccountsApi
(
api_client
)
organizations
=
accounts_api
.
get_organizations
()
org_dict
=
organizations
.
to_dict
()
first_org
=
org_dict
[
"organizations"
][
0
]
org_id
=
first_org
[
"id"
]
return
org_id
def
check_user_exists_by_email
(
user_email
):
access_token
=
session
[
"ds_access_token"
]
api_client
=
ApiClient
(
host
=
DS_CONFIG
[
"admin_api_client_host"
])
api_client
.
set_default_header
(
header_name
=
"Authorization"
,
header_value
=
f"Bearer
{
access_token
}
"
)
users_api
=
UsersApi
(
api_client
)
response
=
users_api
.
get_users
(
organization_id
=
get_organization_id
(),
email
=
user_email
)
return
len
(
response
.
users
)
>
0
and
response
.
users
[
0
].
user_status
!=
"closed"
Back
|
FazBrowse Home
|
New Git URL