Hi there,
Apologies that I have tried to understand this but really can't get it...
I use a script to report on contents of specific folders - particularly to get reports on formats and size.
The script taken from James' previously supplied examples (and edited a bit) has worked until recently when I get an error message relating to 2FA.
I presume I need to change the way I input store my password information, but I'm afraid I have no idea how to put this into the code / files.
Just to note we have used 2FA within Preservica for some time now.
Any advice / help appreciated!
Many thanks
Laura
Script used as below from James examples (I have taken out my account details throughout):
from pyPreservica import *
content = ContentAPI()
entity = EntityAPI()
folder = entity.folder("f78fc2a3-6e66-48f9-9527-fa2131806ade")
print(f"Searching inside folder {folder.title}")
if __name__ == '__main__':
metadata_fields = {
"xip.reference": "*", "xip.title": "", "xip.description": "", "xip.document_type": "*", "xip.parent_hierarchy": f"{folder.reference}",
"xip.security_descriptor": "*",
"xip.identifier": "", "xip.bitstream_names_r_Preservation": "", "xip.format_r_Preservation": "", "xip.size_r_Preservation": ""}
content.search_callback(content.ReportProgressCallBack())
content.search_index_filter_csv("%", "assetsinfo.csv", metadata_fields)
.................................................................................................
And then credentials file stored in same folder:
[credentials]
username=[myusername]
password=[mypassword]
tenant=[ourtenant]
server=[europeserver]
...............................................................................................
Returns following error:
Failed to create a password based authentication token. Check your credentials are correct
b'{"success":false,"message":"needs.2fa","user":"[myusername]","tenant":"[ourtenant]","continuationToken":"57a4ae34-d62f-4a8b-9e36-8ea61a9cd156"}'
Traceback (most recent call last):
File "C:\Users\uazlp\Desktop\API.Workshop\formatandsizereport.py", line 3, in <module>
content = ContentAPI()
File "C:\Users\uazlp\AppData\Local\Programs\Python\Python310\lib\site-packages\pyPreservica\contentAPI.py", line 22, in __init__
super().__init__(username, password, tenant, server, use_shared_secret)
File "C:\Users\uazlp\AppData\Local\Programs\Python\Python310\lib\site-packages\pyPreservica\common.py", line 838, in __init__
self.token = self.__token__()
File "C:\Users\uazlp\AppData\Local\Programs\Python\Python310\lib\site-packages\pyPreservica\common.py", line 759, in __token__
raise RuntimeError(response.status_code, msg)
RuntimeError: (401, 'Failed to create a password based authentication token. Check your credentials are correct')