Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

httpie-ems-auth-0.2.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

httpie_ems_auth-0.2.1-py2.7.egg (4.6 kB view details)

Uploaded Source

File details

Details for the file httpie-ems-auth-0.2.1.tar.gz.

File metadata

File hashes

Hashes for httpie-ems-auth-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4fac0e91cb0bb73413b2196aa308caa03977b2dd5f7169203da4f0b396724f7a
MD5 d1b70f78e0b1041e135941433b4581ab
BLAKE2b-256 283743d242c33c6fcf06fa4061285655086fd0ab7cba123010e46ec3d63a691d

See more details on using hashes here.

File details

Details for the file httpie_ems_auth-0.2.1-py2.7.egg.

File metadata

File hashes

Hashes for httpie_ems_auth-0.2.1-py2.7.egg
Algorithm Hash digest
SHA256 5ef1160b2a575eb5dbc22997ee941c2e9726120280a883aa5b81e0a3877ebac8
MD5 7c9fc117992df4bba0fc32068b99a499
BLAKE2b-256 f2df5ebd253dd431c8b8c8744c20ff5e5fdc12ca275243028e04c7db1193583b

See more details on using hashes here.

Supported by

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