-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the ability to get TOTP tokens #11
base: main
Are you sure you want to change the base?
Conversation
@@ -595,6 +595,35 @@ def get_secret(self) -> str: | |||
self.item.load_secret_sync() | |||
return self.item.get_secret().get_text() | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove superfluous newline :)
|
||
Returns: | ||
TOTP token | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove superfluous newline :)
if otp_value[0] == "secret": | ||
return pyotp.TOTP(otp_value[1]).now() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove superfluous newline :)
return | ||
|
||
if "totp" in self.item.get_attributes().get('otp'): | ||
otp_value = self.item.get_attributes().get('otp').split("?")[1].split("&")[0].split("=") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the actual format here? Is this always the same? Can you provide a example string?
It is really unfortunate that one cannot obtain the current OTP via KeePass directly and has to use an additional library. However, I agree that this is probably the best workaround 🤔 |
Hi all,
I have fixed the quick 'hack' and now added the ability to Opt-In to get a TOTP token.
Furthermore, it was not possible to get the new token with get_attributes() after the time has run out.
I also tried reloading the whole database which did not seem to work.
As such, I had to include a library which generates the TOTP when pressing Ctrl + t.
The feature can be activated by setting view_totp = True.
The following library is needed to generate the TOTP:
pyotp
It is to note, that the library is only needed when copying a TOTP token and would not be needed if deactivated. (Check source code)
Cheers