Git Product home page Git Product logo

key-vault-python-authentication's Introduction

services platforms author
key-vault
python
schaabs

DISCLAIMER: The data plane samples in this repo are for azure-keyvault. In the interest of simplifying APIs, azure-keyvault and KeyVaultClient have been split into separate packages and clients. For samples using these latest packages, please visit:

This repo is archived since azure-keyvault-x packages have become stable. For the latest management plane package, please visit azure-mgmt-keyvault.

DISCLAIMER: If you are looking to migrate from azure-keyvault to azure-keyvault-x, we suggest getting started with the following migration guides:

Authentication samples for Azure Key Vault using the Azure Python SDK

This Sample repo includes sample code demonstrating common mechanism for authenticating to an Azure Key Vault vault.

Samples in this repo

  • authentication_sample.py
    • auth_using_service_principle_credentials -- authenticates to an Azure Key Vault vault using AAD service principle credentials
    • auth_using_adal_callback -- authenticates to an Azure Key Vault vault by providing a callback to authenticate using adal

Running The samples

  1. If you don't already have it, install Python.

  2. We recommend using a virtual environment to run this example, but it's not mandatory. You can initialize a virtual environment this way:

    pip install virtualenv
    virtualenv mytestenv
    cd mytestenv
    source bin/activate
    
  3. Clone the repository.

    git clone https://github.com/Azure-Samples/key-vault-python-authentication.git
    
  4. Install the dependencies using pip.

    cd key-vault-python-authentication
    pip install -r requirements.txt
    
  5. Create an Azure service principal, using Azure CLI, PowerShell or Azure Portal.

  6. Export these environment variables into your current shell.

    export AZURE_TENANT_ID={your tenant id}
    export AZURE_CLIENT_ID={your service principal AppID}
    export AZURE_CLIENT_OID={your service principal OID}
    export AZURE_CLIENT_SECRET={your application key}
    export AZURE_SUBSCRIPTION_ID={your subscription id}
    
  7. Run the samples, optionally specifying a space delimited list of specific samples to run.

    python run_all_samples.py [samplename[ samplename...]]
    

Minimum Requirements

Python 2.7, 3.3, or 3.4. To install Python, please go to https://www.python.org/downloads/

More information

Contributing

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

key-vault-python-authentication's People

Contributors

mccoyp avatar schaabs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

key-vault-python-authentication's Issues

Install Error

Hi,

I'm running into an install error. I'm using an Azure Data Science VM:

Requirement already satisfied: six==1.11.0 in /data/anaconda/envs/py36/lib/python3.6/site-packages (from -r requirements.txt (line 26)) (1.11.0) Requirement already satisfied: urllib3==1.23 in /data/anaconda/envs/py36/lib/python3.6/site-packages (from -r requirements.txt (line 27)) (1.23) Requirement already satisfied: secretstorage; sys_platform == "linux" and python_version >= "3.5" in /data/anaconda/envs/py36/lib/python3.6/site-packages (from keyring==13.1.0->-r requirements.txt (line 16)) (3.1.1) Requirement already satisfied: jeepney in /data/anaconda/envs/py36/lib/python3.6/site-packages (from secretstorage; sys_platform == "linux" and python_version >= "3.5"->keyring==13.1.0->-r requirements.txt (line 16)) (0.4) ERROR: azureml-core 1.0.33.1 has requirement adal>=1.2.0, but you'll have adal 1.0.2 which is incompatible. ERROR: azureml-core 1.0.33.1 has requirement cryptography!=1.9,!=2.0.*,!=2.1.*,!=2.2.*, but you'll have cryptography 2.2.2 which is incompatible. Installing collected packages: certifi, requests, adal, azure-nspkg, azure-common, entrypoints, keyring, oauthlib, requests-oauthlib, msrest, msrestazure, azure-keyvault, azure-mgmt-nspkg, azure-mgmt-keyvault, azure-mgmt-resource, pywin32-ctypes Found existing installation: certifi 2019.3.9 ERROR: Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

I altered the requirements.txt file with updated library versions for cryptography (2.6.1) and adal (1.2.1), but I'm still running into this error which I'm not sure how to resolve:

ERROR: Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.