No project description provided
Project description
A module for easily storing and retriving API credentials in a database.
We all know it’s a bad practice to save API credentials in our code, but almost every example of working with an API, instructu you to go just that. the top four lines of every sample API script starts like this
# Assign appropriate values to these variables
sample_host = "https://baseurl.com/endpoint/path"
sample_script_key = "YOUR PRIVATE KEY"
sample_user = "YOUR USERNAME"
sample_password = "YOUR PASSWORD"
My goal is to create an easy to use module that will allow you to protect youe credentials, by only allowing the script to access them at runtime.
import apikeystore as aks
import requests
#create new vault
myvault = aks.Vault("Test-vault1.db")
myvault.new()
mycreds = aks.Creds(vaultName="Test-vault1.db")
credDetails = {
'appName' : 'virusTotal',
'urlBase' : 'https://www.virustotal.com/vtapi/v2/',
'userId' : '',
'appKey' : 'cf51cae902609f18f1f37b33c79eb9ad559c599d29441592e1ca1c4c48d175ab',
'authType': 'basic'
}
mycreds.addCreds(**credDetails)
mycreds = aks.Creds(vaultName="Test-vault1.db")
vTcred = mycreds.getCred(appName='virusTotal')
vTendpoint = vTcred['urlBase'] + 'file/report?'
payload = {
'resource': '993dcc7f09c690c6f1d3049b3f66092451f2e82536cf81d15ceef447bc4b3b27',
'apikey' : vTcred['appKey']
}
r = requests.get(vTendpoint, params=payload)
print(r.status_code)
#r.json()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
apikeystore-0.0.9.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for apikeystore-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 426c5a133cfb212b02c0e4b185db7f1296b8f8d9787f3a10fde946fbc1d02287 |
|
MD5 | 1136ed5cc40a6c73690bd9e4d955ee0d |
|
BLAKE2b-256 | 23339b98e98e8707db63f1fd7b24698b4e9a4dbe674bced4f8fc05f7dd08ef53 |