All Projects → globocom → tornado-alf

globocom / tornado-alf

Licence: MIT license
Tornado Oauth 2 client

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to tornado-alf

Flask Easy Template
A template web app with Flask. Features: latest bootstrap, user registry, login, forgot password. Secured admin panel, pagination, config files for Nginx and Supervisor and much more.
Stars: ✭ 154 (+805.88%)
Mutual labels:  tornado
Arsenic
Async WebDriver implementation for asyncio and asyncio-compatible frameworks
Stars: ✭ 209 (+1129.41%)
Mutual labels:  tornado
pait
Python Modern API Tools, fast to code
Stars: ✭ 24 (+41.18%)
Mutual labels:  tornado
Elasticsearch Gmail
Index your Gmail Inbox with Elasticsearch
Stars: ✭ 1,964 (+11452.94%)
Mutual labels:  tornado
Elasticsearch Test Data
Generate and upload test data to Elasticsearch for performance and load testing
Stars: ✭ 194 (+1041.18%)
Mutual labels:  tornado
Pypress Tornado
pypress rework by tornado
Stars: ✭ 226 (+1229.41%)
Mutual labels:  tornado
Pychat
webchat via WebSockets/WebRTC that allows messaging/video call/screen sharing
Stars: ✭ 152 (+794.12%)
Mutual labels:  tornado
kdniao python
快递鸟 kdniao python sdk, with tornado async & asyncio http client support.
Stars: ✭ 25 (+47.06%)
Mutual labels:  tornado
Torcms
Flexible, extensible web CMS framework built on Tornado.
Stars: ✭ 197 (+1058.82%)
Mutual labels:  tornado
Opendevops
CODO是一款为用户提供企业多混合云、一站式DevOps、自动化运维、完全开源的云管理平台、自动化运维平台
Stars: ✭ 2,990 (+17488.24%)
Mutual labels:  tornado
Dnsmasqweb
基于DNSmasq的DNS解析、以及DHCP地址分配系统
Stars: ✭ 166 (+876.47%)
Mutual labels:  tornado
Hrshell
HRShell is an HTTPS/HTTP reverse shell built with flask. It is an advanced C2 server with many features & capabilities.
Stars: ✭ 193 (+1035.29%)
Mutual labels:  tornado
Gidgethub
An async GitHub API library for Python
Stars: ✭ 226 (+1229.41%)
Mutual labels:  tornado
Webssh
🌱 Web based ssh client
Stars: ✭ 2,520 (+14723.53%)
Mutual labels:  tornado
tornado-upload
File Upload Application for Tornado
Stars: ✭ 41 (+141.18%)
Mutual labels:  tornado
Fp Server
Free proxy server, continuously crawling and providing proxies, based on Tornado and Scrapy. 免费代理服务器,基于Tornado和Scrapy,在本地搭建属于自己的代理池
Stars: ✭ 154 (+805.88%)
Mutual labels:  tornado
Collipa
The source code of Collipa
Stars: ✭ 217 (+1176.47%)
Mutual labels:  tornado
rabbitChat
A Chat-Server/Chat-System based on AMQP protocol(RabbitMQ) + AMQP Python Client(PIKA) + Websockets(SockJS) + Async Python Server(Tornado)
Stars: ✭ 53 (+211.76%)
Mutual labels:  tornado
mypy-playground
The mypy playground. Try mypy with your web browser.
Stars: ✭ 58 (+241.18%)
Mutual labels:  tornado
Fpage
Tornado project generator. Start a project with tornado, mako/jinjia2 and sqlalchemy/peewee in a minute.
Stars: ✭ 242 (+1323.53%)
Mutual labels:  tornado

tornado-alf build-status

Tornado OAuth 2 Client

tornado-alf is a OAuth 2 Client base on the tornado's AsyncHTTPClient

Features

  • Automatic token retrieving and renewing
  • Token expiration control
  • Automatic retry on status 401 (UNAUTHORIZED)

Usage

Initialize the client and use it as a AsyncHTTPClient object.

from tornadoalf.client import Client
from tornadoalf.httpclient import HTTPRequest

client = Client(
    token_endpoint='http://example.com/token',
    client_id='client-id',
    client_secret='secret')

resource_uri = 'http://example.com/resource'

response = await client.fetch(HTTPRequest(resource_uri),
    method='POST', body='{"name": "alf"}',
    headers={'Content-Type': 'application/json'})

Alternatively one can pass directly a string to the fetch client

# ...
response = await client.fetch('http://example.com/resource',
    method='POST', body='{"name": "alf"}',
    headers={'Content-Type': 'application/json'})

How it works?

Before any request the client tries to retrieve a token on the endpoint, expecting a JSON response with the access_token and expires_in keys.

The client keeps the token until it is expired, according to the expires_in value.

After getting the token, the request is issued with a Bearer authorization header:

GET /resource/1 HTTP/1.1
Host: example.com
Authorization: Bearer token

If the request fails with a 401 (UNAUTHORIZED) status, a new token is retrieved from the endpoint and the request is retried. This happens only once, if it fails again the error response is returned.

Troubleshooting

In case of an error retrieving a token, the error response will be returned, the real request won't happen.

Related projects

This project tries to be an adaptation to tornado of alf

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].