{
"info": {
"author": "Greg Aker",
"author_email": "greg@gregaker.net",
"bugtrack_url": null,
"classifiers": [
"Environment :: Web Environment",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy"
],
"description": "==================\nVinli Tornado Auth\n==================\n\n`Vinli `_ platform auth wrapper for `Tornado `_ \n\n------------\nInstallation\n------------\n\n::\n\n pip install vinli-tornado-auth\n\n---------------------\nSettings Requirements\n---------------------\n\nRegister and create an app at `https://dev.vin.li `_\n\nIn the app, create a ``web`` client type and take note of the \nfollowing values:\n\n* ``vinli_client_id`` - App Client Id\n* ``vinli_client_secret`` - App Client Secret\n* ``vinli_redirect_uri`` - A valid URL to redirect to. eg: ``http://localhost:8000/auth/login``\n\nAdd these values to application ``settings``.\n\n-------------\nExample Usage\n-------------\n\n::\n \n import tornado.escape\n import tornado.ioloop\n import tornado.gen\n import tornado.web\n\n from vinli_tornado_auth.auth import VinliAuthLoginMixin\n\n class LoginHandler(tornado.web.RequestHandler, VinliAuthLoginMixin):\n \"\"\"\n Handle /auth/login\n \"\"\"\n @tornado.gen.coroutine\n def get(self):\n code = self.get_argument('code', None)\n if not code:\n yield self.authorize_redirect(\n redirect_uri=self.settings['vinli_redirect_uri'],\n client_id=self.settings['vinli_client_id'],\n response_type='code'\n )\n else:\n access = yield self.get_authenticated_user(\n redirect_uri=self.settings['vinli_redirect_uri'],\n code=code\n )\n user = yield self.oauth2_request(\n self._OAUTH_USERINFO_URL,\n access_token=access['access_token']\n )\n self.set_secure_cookie(\n 'user', tornado.escape.json_encode({\n 'user': user,\n 'token': access['access_token']\n })\n )\n self.redirect('/')\n\n\n class IndexHandler(tornado.web.RequestHandler, VinliAuthLoginMixin):\n \"\"\"\n Handle /\n \"\"\"\n def get_current_user(self):\n user = self.get_secure_cookie('user')\n if not user:\n return None\n return tornado.escape.json_decode(user)\n\n @tornado.web.authenticated\n @tornado.gen.coroutine\n def get(self):\n devices = yield self.vinli_request(\n 'platform', '/api/v1/devices',\n access_token=self.current_user.get('token')\n )\n self.write(devices)\n\n\n class Application(tornado.web.Application):\n def __init__(self):\n settings = {\n 'vinli_client_id': 'abc123',\n 'vinli_client_secret': \"shhhh it is secret\",\n 'vinli_redirect_uri': 'http://localhost:8000/auth/login',\n 'cookie_secret': '12345',\n }\n urls = [\n (r'/', IndexHandler),\n (r'/auth/login', LoginHandler),\n ]\n super(Application, self).__init__(urls, **settings)\n\n\n if __name__ == '__main__':\n app = Application()\n app.listen(8000)\n tornado.ioloop.IOLoop.instance().start()\n\n\n-----------------------------\nMaking Authenticated Requests\n-----------------------------\n\nUse the ``vinli_request`` method to make authenticated requests to\nthe platform after initial authentication has been completed.\n\nGet Trips for a device\n^^^^^^^^^^^^^^^^^^^^^^\n\nAs with the `following example `_\nfrom the Vinli API Documentation, a list of trips for device id\n``fe4bbc20-cc90-11e3-8e05-f3abac5b6b58`` can be retrieved with the following::\n\n @tornado.web.authenticated\n @tornado.gen.coroutine\n def get(self):\n trips = yield self.vinli_request(\n 'trips', '/api/v1/devices/fe4bbc20-cc90-11e3-8e05-f3abac5b6b58/trips',\n access_token=self.current_user.get('token')\n )\n self.write(trips)",
"description_content_type": null,
"docs_url": null,
"download_url": "https://github.com/gaker/vinli-tornado-auth/archive/0.1.0.tar.gz",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/gaker/vinli-tornado-auth",
"keywords": null,
"license": "UNKNOWN",
"maintainer": null,
"maintainer_email": null,
"name": "vinli_tornado_auth",
"package_url": "https://pypi.org/project/vinli_tornado_auth/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/vinli_tornado_auth/",
"project_urls": {
"Download": "https://github.com/gaker/vinli-tornado-auth/archive/0.1.0.tar.gz",
"Homepage": "https://github.com/gaker/vinli-tornado-auth"
},
"release_url": "https://pypi.org/project/vinli_tornado_auth/0.1.0/",
"requires_dist": null,
"requires_python": null,
"summary": "Tornado web authentication for the Vinli Platform.",
"version": "0.1.0"
},
"last_serial": 2113455,
"releases": {
"0.1.0": [
{
"comment_text": "",
"digests": {
"md5": "ea9a3418d64d11dd71661a339971cdaa",
"sha256": "d79f15993367903f381871be1f92c4e6f477829c2ce68e290475f46b0286b8d9"
},
"downloads": -1,
"filename": "vinli_tornado_auth-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "ea9a3418d64d11dd71661a339971cdaa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4649,
"upload_time": "2016-05-13T00:43:14",
"url": "https://files.pythonhosted.org/packages/17/9a/1ace78d9ba743a851414748aa297527e5409640a8339896e01e6a61eec35/vinli_tornado_auth-0.1.0.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "ea9a3418d64d11dd71661a339971cdaa",
"sha256": "d79f15993367903f381871be1f92c4e6f477829c2ce68e290475f46b0286b8d9"
},
"downloads": -1,
"filename": "vinli_tornado_auth-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "ea9a3418d64d11dd71661a339971cdaa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4649,
"upload_time": "2016-05-13T00:43:14",
"url": "https://files.pythonhosted.org/packages/17/9a/1ace78d9ba743a851414748aa297527e5409640a8339896e01e6a61eec35/vinli_tornado_auth-0.1.0.tar.gz"
}
]
}