forked from shubhamdipt/passbolt-python-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
34 lines (27 loc) · 1023 Bytes
/
test.py
File metadata and controls
34 lines (27 loc) · 1023 Bytes
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
import passboltapi
def get_my_passwords(passbolt_obj):
result = []
for i in passbolt_obj.get(url="/resources.json?api-version=v2")["body"]:
result.append({
"id": i["id"],
"name": i["name"],
"username": i["username"],
"uri": i["uri"],
})
print(i)
for i in result:
resource = passbolt_obj.get(
"/secrets/resource/{}.json?api-version=v2".format(i["id"]))
i["password"] = passbolt_obj.decrypt(resource["body"]["data"])
print(result)
def main():
# A simple example to show how to retrieve passwords of a user.
# Note the config file is placed in the project directory.
passbolt = passboltapi.PassboltAPI(config_path="config.ini")
get_my_passwords(passbolt_obj=passbolt)
passbolt.close_session()
# Or using context managers
with passboltapi.PassboltAPI(config_path="config.ini") as passbolt:
get_my_passwords(passbolt_obj=passbolt)
if __name__ == "__main__":
main()