EmsAuth plugin for HTTPie.
Project description
This HTTPie auth plugin implements Escher authentication for Emarsys API requests.
Installation
Be sure that HTTPie is installed, and install this plugin:
$ pip install httpie-ems-auth
After installing, you will see the option ems-auth under --auth-type if you run $ http --help.
Example
Suiteable if you call the API of Suite
$ http --auth-type=ems-auth --auth=escher_key:escher_secret https://api.emarsys.net/api/v2/internal/12345678/settings
The default Escher credential scope is “eu/suite/ems_request” which identifies Suite. If u are calling another service, you have to alter the credential scope like this:
$ http --auth-type=ems-auth --auth=eu/suite/ems_request/escher_key:escher_secret https://api.emarsys.net/api/v2/internal/12345678/settings
Check out HTTPie sessions if you would like to save authentication information between your requests.
- If you want to use in python code this example can help:
import escherauth import datetime from urlparse import urlparse import requests escher_key = 'test' escher_secret = 'test' options = { 'algo_prefix': 'EMS', 'vendor_key': 'EMS', 'hash_algo': 'SHA256', 'auth_header_name': 'X-Ems-Auth', 'date_header_name': 'X-Ems-Date' } credential_scope = "test" if "/" in escher_key: scope = escher_key.split("/") escher_key = scope.pop() credential_scope = "/".join(scope) client = {'api_key': escher_key, 'api_secret': escher_secret} escher = escherauth.Escher(credential_scope, options) url = 'http://test-escher-url.com/api/call/smth' r = requests.PreparedRequest() r.prepare('GET',url) now = datetime.datetime.utcnow() r.headers['X-Ems-Date'] = now.strftime('%Y%m%dT%H%M%SZ') parsed_uri = urlparse(r.url) r.headers['Host'] = parsed_uri.netloc f = escher.sign(r, client) s = requests.Session() s.send(f)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file httpie-ems-auth-p3-0.2.3.tar.gz.
File metadata
- Download URL: httpie-ems-auth-p3-0.2.3.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52bd36adeeaf7df11fdfe4f24df4b14e4063a74f544cc2efcf891b8c90ea67e7
|
|
| MD5 |
179dc1c21ded161938ff63a031d506df
|
|
| BLAKE2b-256 |
44adfc5be78495f455b44c9b0ee8a50e8ddbb3ea5bbdf41ffc35b1a8c9da0fea
|
File details
Details for the file httpie_ems_auth_p3-0.2.3-py2.7.egg.
File metadata
- Download URL: httpie_ems_auth_p3-0.2.3-py2.7.egg
- Upload date:
- Size: 4.6 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa6015fb7a9cad7e588eaed6f04946b7f6d6eb34c109e4208266f195329723de
|
|
| MD5 |
d0afd0ebb63ae18212bff1853e083cc1
|
|
| BLAKE2b-256 |
ae8cbdfe097c6d3d5029d3459152963b435c90855e00cd1035f234089aa1a269
|