-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_ccg_switch.py
39 lines (28 loc) · 1.12 KB
/
test_ccg_switch.py
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
"""Test configuration for developer token access"""
import logging
from box_sdk_gen import BoxCCGAuth, BoxClient, CCGConfig, FileWithInMemoryCacheTokenStorage
from utils.box_client_ccg import ConfigCCG
logging.basicConfig(level=logging.INFO)
logging.getLogger("box_sdk_gen").setLevel(logging.CRITICAL)
def main():
config = ConfigCCG()
ccg = CCGConfig(
client_id=config.client_id,
client_secret=config.client_secret,
enterprise_id=config.enterprise_id,
token_storage=FileWithInMemoryCacheTokenStorage(".ent" + config.cache_file),
)
auth = BoxCCGAuth(ccg)
client = BoxClient(auth)
me = client.users.get_user_me()
print(f"\nHello, I'm {me.name} ({me.login}) [{me.id}]")
auth = auth.with_user_subject(config.ccg_user_id)
client = BoxClient(auth)
me = client.users.get_user_me()
print(f"\nHello, I'm {me.name} ({me.login}) [{me.id}]")
auth = auth.with_enterprise_subject(config.enterprise_id)
client = BoxClient(auth)
me = client.users.get_user_me()
print(f"\nHello, I'm back to {me.name} ({me.login}) [{me.id}]")
if __name__ == "__main__":
main()