MBQ Service Client
Project description
Installation
$ pip install mbq.client
Getting Started
Key Concepts
ServiceClient wraps python’s requests library to enable token based service to service authentication
Authenticator provides Auth0 token based authentication
TokenManager A manager that stores refreshable tokens with support for different persistent storage backends.
Django Integration
DjangoCacheStorage is a thin wrapper that stores token in your django project’s cache.
Example
from django.core.cache import cache
from mbq.client import ServiceClient, Authenticator, TokenManager, DjangoCacheStorage
token_manager = TokenManager(
settings={
'api_ids': {'my_service': 'id'},
'client_id': 'client_id',
'client_secret': 'your_secret'
'domain': 'auth0domain'
},
storage=DjangoCacheStorage(cache),
)
my_service_client = ServiceClient(
auth=Authenticator(
service_name='my_service',
token_manager=token_manager
)
)
my_service_client.get()
my_service_client.post()
my_service_client.patch()
my_service_client.put()
my_service_client.delete()
access_token.refresh()
access_token() #retrieves token
The Permissions Client
OSCore = ServiceClient(
settings.OS_CORE_API_URL,
auth=Authenticator(
service_name="os-core",
token_manager=token_manager
),
)
from mbq.client.contrib import permissions
permissions_client = permissions.PermissionsClient(
permissions.OSCoreServiceClient(OSCore),
cache_period_seconds=0
)
# query for a user's permission at company 15
permissions_client.has_permission(person_id, "read:messages", 15, "company") # returns True if person_id has that permission
You can find additional information in the permissions documentation for developers here
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
mbq.client-1.5.1.tar.gz
(13.7 kB
view details)
File details
Details for the file mbq.client-1.5.1.tar.gz.
File metadata
- Download URL: mbq.client-1.5.1.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab3c8f60baeddac51ebb510361d208ad1ed4e77b614ad97396c1bdde869b0253
|
|
| MD5 |
791e5813e8d0fa6d0f19a1616ff361cc
|
|
| BLAKE2b-256 |
92d5d86b2839a2876f9c258c6150c8e970dee34f3216a9f4d756faa14b474902
|