Files
Place-Order-Trading-Bot/login2keyring.ipynb
T
2025-05-27 13:23:26 +02:00

3.8 KiB

Import Libaries

In [3]:
import keyring as kr

Save Pwd to keyring

  • servicename – The name of the service i.e to a certain organization with which the person is related to.
  • username – Username of the person.
  • password – Password associated with that username.
kr.set_password("servicename","username","pwd")
In [1]:
# Live Acccount
login = 10676507
password = '5l5^hbEL'
server = 'VantageInternational-Live 4'
In [7]:
# Demo Acccount
login = 10800246
password = '%dN!Zu96'
server = 'VantageInternational-Demo'
In [8]:
kr.set_password(server, str(login), password)

Get Password

To retrieve the saved password we will use the get_password() method. It takes two parameters.

  • Servicename
  • Username
print(kr.get_password("Servicename","Username"))
In [4]:
print(kr.get_password(server,str(login)))
5l5^hbEL

Retrievieng Credentials

In [5]:
cred = kr.get_credential(server,"") 
  
print("Username : ",cred.username) 
print("Password : ",cred.password)
Username :  10676507
Password :  5l5^hbEL

Delete from Keyring

To delete a password we will use the delete_password() method. It also takes two parameters:

  • Servicename
  • Username
kr.delete_password("Servicename", "Username") 
In [4]:
kr.delete_password(server, str(login)) 
In [5]:
print(kr.get_password(server, str(login)))
None
In [ ]: