Skip to main content

OVH auth plugin for HTTPie.

Project description

Auth plugin for OVH API

httpie_ovh_auth in a nutshell

This plugin allows, based on OVH_CLIENT_ID, OVH_CLIENT_SECRET and OVH_CONSUMER_KEY to perform OVH API calls with httpie tool.

# Configure an OVH application to get OVH_CLIENT_ID, OVH_CLIENT_SECRET
# Perform authentication to get OVH_CONSUMER_KEY
# Setup environment variables
# Perform OVH API calls with httpie
http -b --auth-type ovh https://api.ovh.com/1.0/me

Obtain API credentials

You can find URLs to create your application credentials (client id and secret) here: https://github.com/ovh/python-ovh#1-create-an-application

Then, you need to perform a customer key request and validation.

# Replace $OVH_CLIENT_ID with the appropriate value
# Add needed method and path in accessRules list
http -b post https://api.ovh.com/1.0/auth/credential X-Ovh-Application:$OVH_CLIENT_ID accessRules:='[{"method": "GET", "path": "/*"}]'
{
    "consumerKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "state": "pendingValidation",
    "validationUrl": "https://eu.api.ovh.com/auth/?credentialToken=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

Visit validationUrl to validate your consumer key (you need to authenticate and choose an expiration delay).

Credentials from environment variables

Plugin can use environement variables OVH_CLIENT_ID, OVH_CLIENT_SECRET and OVH_CONSUMER_KEY to perform httpie authentication. OVH_CLIENT_* come from application creation. OVH_CONSUMER_KEY is the consumerKey attribute obtained from credential validation.

Rename auth.env.tpl to auth.env and insert your credentials.

Configure your environment before running httpie commands by sourcing this file:

# Setup environment variables
source auth.env
# Check authentication setup with profile API
http -b --auth-type ovh https://api.ovh.com/1.0/me

Credentials with -a option

Not yet implemented.

Credentials with configuration file

Not yet implemented.

Interactive credential generation

Not yet implmented.

OVH API resources

Here is the official API implementation: https://github.com/ovh/python-ovh (this library does not depend on python-ovh).

API documentation available here: https://api.ovh.com/

Development

## install pipenv
# dnf install pipenv or apt install pipenv
## init virtualenv with pipenv
pipenv install --dev
## launch tests in pipenv environment
pipenv run pytest
## launch tests for all envs
pipenv run tox

Release

Stable branch is main; development branch is dev. Usual release steps are :

# install dev tools and switch in pipenv
pipenv install --dev
pipenv shell

# if needed, update Pipfile.lock and commit changes
pipenv lock --clear
pipenv install --dev

# prepare dev branch for release...
# check CHANGELOG.md, README.md, ...
# ...
# update version if needed (example: VERSION=1.1.0.dev0 to release 1.1.0)
git fetch
git checkout dev
git pull
tbump VERSION

# open a PR for version releasing
# PR merge triggers:
# * Build devN version
# * trigger version minor increment
# * trigger tag creation, dev branch update (version, merge)
# * tag is published

Github actions

This actions are automatically triggered:

  • Build and test on python 3.7-3.10 environments for all branches and PR
  • Build and publish on test.pypi.org for all protected branches and PR; publication is ignored if version is already deployed
  • For merged PR on main branch: version increment (minor), tag, dev merge back and version, build and publish on pypi

Github actions configuration

testpypi and pypi environments are needed. Needed secrets are:

  • PYPI_TOKEN
  • GPG_PRIVATE_KEY (optional)
  • GPG_PASSPHRASE (optional)

GPG_* values are the same for both environments.

Manual publication

If needed, release can be manually performed.

# Manual publication
# publish (pypi credentials required)
tbump RELEASE_VERSION
git checkout vRELEASE_VERSION
rm -rf dist build
python -m build --sdist --wheel
# fake upload
# run pypi-server in another shell
mkdir -p /tmp/packages && pypi-server run -P . -a . /tmp/packages/
twine upload  -u "" -p "" --repository-url http://localhost:8080/ dist/*.whl dist/*.tar.gz

# real upload
twine upload dist/*.whl dist/*.tar.gz

Changelog

1.2.0 (2022-07-18)

  • remove python 3.6 support
  • added python 3.10 tests
  • build system updated (pep 517, pep 660)
  • restored CI (github-actions based)

1.1.0 (2022-07-04)

  • fix httpie body type (bytes, we need to convert to str)

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

httpie-ovh-auth-1.2.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

httpie_ovh_auth-1.2.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file httpie-ovh-auth-1.2.0.tar.gz.

File metadata

  • Download URL: httpie-ovh-auth-1.2.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for httpie-ovh-auth-1.2.0.tar.gz
Algorithm Hash digest
SHA256 da7a6d02973e5829e8f02fba005dbd2cb248ab76f7e5a79ecd98b9b1aff421e6
MD5 d503dce4ab28767dc199f48c7947d1e9
BLAKE2b-256 b6fe92bfeaa68c74bccf262f371b9e8fcfac11cc5f931ed9040688380ec5c656

See more details on using hashes here.

File details

Details for the file httpie_ovh_auth-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for httpie_ovh_auth-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67419112f3233381b1edd1c2b044090fa3f4bf3ea826c63a53a798d5927f7ef4
MD5 8ed2093a4377335d9e452239143d8799
BLAKE2b-256 43f4dd88eab8c4764bab8e93bf58f974df4e4934a56c2fd1f483e498de6d2b31

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