Skip to main content

No project description provided

Project description

buildVersion buildStatus MitLicense

pythonVersion


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


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)

Uploaded Source

Built Distribution

apikeystore-0.0.9-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page