@@ -23,6 +23,8 @@ import getpass
23
23
24
24
from descarteslabs.auth import Auth, base64url_decode
25
25
26
+ import descarteslabs as dl
27
+
26
28
if __name__ == "__main__":
27
29
28
30
parser = argparse.ArgumentParser()
@@ -35,10 +37,9 @@ if __name__ == "__main__":
35
37
36
38
if args.command == 'login':
37
39
38
- print(
39
- 'Follow this link to login: https://iam.descarteslabs.com/auth/login?refresh_token=true&destination=/auth/refresh_token')
40
+ print('Follow this link to login https://iam.descarteslabs.com/auth/login?refresh_token=true&destination=/auth/refresh_token')
40
41
41
- s = getpass.getpass ('...then come back and paste the generated token here : ')
42
+ s = raw_input ('...then come back here and paste the generated token: ')
42
43
43
44
if s:
44
45
@@ -58,18 +59,36 @@ if __name__ == "__main__":
58
59
59
60
os.chmod(file, stat.S_IRUSR | stat.S_IWUSR)
60
61
62
+ keys = dl.metadata.keys()
63
+
64
+ name = auth.payload['name']
65
+ groups = ', '.join(auth.payload['groups'])
66
+
67
+ if len(keys):
68
+
69
+ print('Welcome, %s!' % name)
70
+
71
+ else:
72
+
73
+ print('Welcome, %s! Your %s role(s) do not permit access to any imagery at this time.' % (name, groups))
74
+ print('Contact
[email protected] if you believe you received this message in error or have any questions.')
75
+
76
+ if args.command == 'token':
77
+ print(auth.token)
78
+
61
79
if args.command == 'name':
80
+ auth.token
62
81
print(auth.payload['name'])
63
82
64
83
if args.command == 'groups':
84
+ auth.token
65
85
print(json.dumps(auth.payload['groups']))
66
86
67
- if args.command == 'token':
68
- print(auth.token)
69
-
70
87
if args.command == 'payload':
88
+ auth.token
71
89
print(auth.payload)
72
90
73
91
if args.command == 'env':
92
+ auth.token
74
93
print('%s=%s' % ('CLIENT_ID', auth.client_id))
75
94
print('%s=%s' % ('CLIENT_SECRET', auth.client_secret))
0 commit comments