Python implementation of the Ruby Signature library (https://github.com/mloughran/signature)
Project description
ApySignature
============
Python implementation of the Ruby Signature library
(https://github.com/mloughran/signature)
Installation
------------
```
pip install apysignature
```
Examples
--------
Client example
```python
from apysignature import signature
params = {'some'='parameters'}
token = signature.Token('my_key', 'my_secret')
request = signature.Request('POST', '/api/thing', params)
auth_hash = request.sign(token)
query_params = params.update(auth_hash)
requests.post('http://myservice/api/thing', data=query_params)
```
`query_params` looks like:
```python
{
'some'='parameters',
'auth_timestamp'=1273231888,
'auth_signature'='28b6bb0f242f71064916fad6ae463fe91f5adc302222dfc02c348ae1941eaf80',
'auth_version'='1.0',
'auth_key'='my_key'
}
```
Server example (Django)
```python
from apysignature import signature
auth_request = signature.Request(request.method, str(request.path), params)
public_key = params['auth_key']
token = signature.Token(public_key, private_key)
try:
auth_request.authenticate(token)
except AuthenticationError as e:
return HttpResponse('Unauthorized', status=401)
# Do whatever you need to do
end
```
Compatibility
---------
Version > 0.2 is for Python 3
use < 0.2 for Python 2
Copyright
---------
Copyright (c) 2014 Erick Ponce. See LICENSE for details.
============
Python implementation of the Ruby Signature library
(https://github.com/mloughran/signature)
Installation
------------
```
pip install apysignature
```
Examples
--------
Client example
```python
from apysignature import signature
params = {'some'='parameters'}
token = signature.Token('my_key', 'my_secret')
request = signature.Request('POST', '/api/thing', params)
auth_hash = request.sign(token)
query_params = params.update(auth_hash)
requests.post('http://myservice/api/thing', data=query_params)
```
`query_params` looks like:
```python
{
'some'='parameters',
'auth_timestamp'=1273231888,
'auth_signature'='28b6bb0f242f71064916fad6ae463fe91f5adc302222dfc02c348ae1941eaf80',
'auth_version'='1.0',
'auth_key'='my_key'
}
```
Server example (Django)
```python
from apysignature import signature
auth_request = signature.Request(request.method, str(request.path), params)
public_key = params['auth_key']
token = signature.Token(public_key, private_key)
try:
auth_request.authenticate(token)
except AuthenticationError as e:
return HttpResponse('Unauthorized', status=401)
# Do whatever you need to do
end
```
Compatibility
---------
Version > 0.2 is for Python 3
use < 0.2 for Python 2
Copyright
---------
Copyright (c) 2014 Erick Ponce. See LICENSE for details.
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
apysignature-0.2.1.tar.gz
(3.9 kB
view details)
File details
Details for the file apysignature-0.2.1.tar.gz
.
File metadata
- Download URL: apysignature-0.2.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42893cfd7b7823da0e1250f567e60957eb30ce1f41b0353236ab264e2440e9cd |
|
MD5 | a3d4f0135c6349cc2bb29eb8028b4b86 |
|
BLAKE2b-256 | 47583cef34cdd4c49491aede67185078518a3c92f5b1ca4f59a8302292780a33 |