Skip to content

Instantly share code, notes, and snippets.

@franTarkenton
Last active June 25, 2019 22:01
Show Gist options
  • Save franTarkenton/09fb0cd7214efe6ba010b9689a502b7c to your computer and use it in GitHub Desktop.
Save franTarkenton/09fb0cd7214efe6ba010b9689a502b7c to your computer and use it in GitHub Desktop.

Overview

The following are instructions for George to get started with encorporating credential retrieval from Password manager pro to support work on the SDE upgrade project.

Installing

I'm gonna provide you with two options for installing. The "right" way and the "cludgy" way.

Installing the "Right Way"

Create a virtualenv

python -m virtualenv ve_restol

Activate the virtualenv

ve_restol/Scripts/activate

Install the dependencies

pip install "git+https://github.com/bcgov/[email protected]#egg=PMP&subdirectory=PMP"

Installing the "Cludgy Way"

Instead of using virtualenv we are going to install the dependencies into as specific directory, then its up to you to make sure that your python interpreter knows to look in that directory for modules either by:

  • creating a usercustomize.py file
  • programatically adding the path to the pythonpath, sys.path to include the directory with the package
  • create a PYTHONPATH env var that defines the path

get the PMP module

cd <install dir>
python -m pip install -t <install dir> -e "git+https://github.com/bcgov/[email protected]#egg=PMP&subdirectory=PMP"

Set up PYTHONPATH

As mentioned above there are a bunch of different ways to do this. Going to show below how you can programatically do this. This is the ugyliest but also the most versatile.

import sys
sys.path = sys.path.append('<used above when you installed PMP>')
import PMP

Getting the credentials

We will provide you with the following information that you can add to the code:

  • apikey / token
  • url to pmp
  • resource names to use.
# define a dictionary with the following info
pmpConfDict = {'token':'<the key that we will provide you>',
               'baseurl': '<The url that we will provide you>',
               'restdir': r'/restapi/json/v1/'}
               
# create a pmp object:
pmp = PMP.PMPRestConnect.PMP(pmpConfDict)

# get a password for a schema
schema = 'WHSE_HOCKEY'
rsrcNm = 'ETL_HOCKEY'
pswd = pmp.getAccountPassword(schema, rsrcNm)

Additional Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment