Skip to main content

Passwork connector

Project description

About the API

Passwork API lets you retrieve, create, update passwords, folders and vaults. It is an easy way how you can integrate Passwork with your infrastructure. Use our Passwork Python Connector to make the integration smoother. The API operates behalf of the user whom API Key is used. Check for all available methods in Passwork API Methods

How to install

⚠️WARNING the connector will not work with python version less than 3.10

git clone https://github.com/passwork-me/python-connector.git .
pip install -r requirements.txt

Environment variables

The following environment variables are required for operation:

HOST: The address of the API server, like https://.../api/v4
API_KEY: Your API key for authentication, instructions for obtaining below
MASTER_PASSWORD: Client-side encryption key. Only add it when client-side encryption is enabled

Several available options for storing environment variables:

  1. .env file
  2. run/debug configuration (IDLE)
  3. system environment variables

API Key

alt text

  • Sign in to your Passwork
  • Menu → API Settings
  • Enter your authorization key and generate the API Key

Use method login() on instance of PassworkAPI class to retrieve a temporary API Token. An API token is a session token. It is valid as long as you are accessing the API. After it expires, you will need to log in again. API Token Lifetime can be set up in your Passwork. The retrieved API token is stored as an instance variable named session_options within the PassworkAPI class and is subsequently sent in an HTTP header.

Step-by-step guide

Create session (common step for all operations)

  1. Create instance of API connection and open session.
from package.passwork_api import PassworkAPI

# A way to overwrite the specified data in environment variables or not use environment variables at all
options_override = {
    "host": str(),
    "api_key": str(),
    "master_password": str(),
}

api = PassworkAPI(options_override=options_override)
api.login()
# api.logout()  # close session after all operations with Passwork API

Password search by parameters

  1. Fill data in search_params dict template with searching parameters to search_password method
search_params = {
    "query": "",
    "tags": [],
    "colors": [],
    "vaultId": None,
    "includeShared": False,
    "includeShortcuts": False,
}
  1. Search password
found_passwords = api.search_password(**search_params)

Get full password info

NOTE PASSWORD_ID must contain the identifier of the target password, in the example a non-existent identifier is specified

  1. Get password and vault items
PASSWORD_ID = "0123456789abcdefghijklmn"
password_item = api.get_password(password_id=PASSWORD_ID)
vault_id = password_item.get("vaultId")
vault_item = api.get_vault(vault_id=vault_id)
  1. Receive vault password and password encryption key
vault_password = api.get_vault_password(vault_item=vault_item)
password_encryption_key = api.get_password_encryption_key(
    password_item=password_item,
    vault_password=vault_password
)
  1. Receive password customs, password plain text and download attachments
password_item["custom"] = api.get_customs(
    password_item=password_item,
    password_encryption_key=password_encryption_key
)

api.get_attachments(
    password_item=password_item,
    password_encryption_key=password_encryption_key
)

password_plain_text = api.get_password_plain_text(
    password_item=password_item,
    password_encryption_key=password_encryption_key
)
  1. Show full password info in readable format
full_password_info = {
    "password": password_item,
    "vault": vault_item,
    "vaultMasterKey": vault_password,
    "passwordMasterKey": password_encryption_key,
    "passwordPlainText": password_plain_text,
}

pretty_data = json.dumps(full_password_info, indent=4)
logger.success(pretty_data)

Add password

NOTE If VAULT_ID is specified, the PASSWORD_ID variable may be empty. Without specifying of VAULT_ID, the identifier of the vault where the password with id = PASSWORD_ID is stored will be taken. The identifiers PASSWORD_ID and VAULT_ID in the example are non-existent.

  1. Receive vault item and vault password
PASSWORD_ID = "0123456789abcdefghijklmn"
VAULT_ID = "0123456789abcdefghijklmn"

vault_id = VAULT_ID if VAULT_ID else api.get_password(password_id=PASSWORD_ID)["vaultId"]
vault_item = api.get_vault(vault_id=vault_id)
vault_password = api.get_vault_password(vault_item=vault_item)
  1. Fill data in password_adding_fields dict template
password_adding_fields = {}
  1. Add password
added_password_info = api.add_password(password_adding_fields, vault_item, vault_password)
logger.success(f"Password with id {added_password_info['id']} has been added")

Delete password

NOTE PASSWORD_ID must contain the identifier of the target password, in the example a non-existent identifier is specified

  1. Delete a password by its id
PASSWORD_ID = "0123456789abcdefghijklmn"
api.delete_password(password_id=PASSWORD_ID)

Examples and algorithm of work with the connector

Examples here

License

This project is licensed under the terms of the MIT license.

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

passwork-0.1.6.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

passwork-0.1.6-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file passwork-0.1.6.tar.gz.

File metadata

  • Download URL: passwork-0.1.6.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.7

File hashes

Hashes for passwork-0.1.6.tar.gz
Algorithm Hash digest
SHA256 feca6708275bb956d10aa15830b2866d6c802099a6f947b7cb6e052f65cc6813
MD5 13690fe12957e44e75176db1fb65f68c
BLAKE2b-256 1dd85ee02a12c17cb54caa9c59a1faf2285e3e3d11fb83f3ec14a7787a82f562

See more details on using hashes here.

File details

Details for the file passwork-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: passwork-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.7

File hashes

Hashes for passwork-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 855d13c82315ab3f36ac8f78dabc9d0497336618befe78b9eeaf171d3886a024
MD5 fcd6b6290d1e3df3a5dd91a5357a98e9
BLAKE2b-256 f13d8b71758c3a7e264aa3b6fd58eee2e8461fedf364d33c51f396e60ae8f128

See more details on using hashes here.

Supported by

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