{ "info": { "author": "allenwhale", "author_email": "allencat850502@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "#NCTU-OAuth\n\n\u53f0\u7063\u570b\u7acb\u4ea4\u901a\u5927\u5b78\u63a8\u51fa [NCTU OAuth]('https://id.nctu.edu.tw/')\n\n\u4f60\u53ef\u4ee5\u900f\u904e\u672c\u5957\u4ef6\u5728tornado\u958b\u767c\u4e2d\u4f7f\u7528NCTU OAuth\n\n\u6839\u64da[\u4ea4\u901a\u5927\u5b78 OAuth \u670d\u52d9 - \u958b\u767c\u8005\u8aaa\u660e\u6587\u4ef6](https://id.nctu.edu.tw/docs/)\u9032\u884c\u5c0d\u61c9\u7684\u958b\u767c\uff0c\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528\u672c\u5957\u4ef6\u7684\u7bc4\u4f8b\n\n```Python\nimport tornado\nimport tornado.web\nimport tornado.ioloop\nimport json\nfrom oauth import NCTUOAuth2Mixin \n\nREDIRECT_URI = 'http://example.com:8080/auth/'\nCLIENT_ID = ''\nCLIENT_SECRET = ''\n\nclass OAuthHandler(tornado.web.RequestHandler, NCTUOAuth2Mixin):\n @tornado.gen.coroutine\n def get(self):\n code = self.get_argument('code', None)\n if code:\n access = yield self.get_authenticated_user(\n redirect_uri=REDIRECT_URI,\n code=code)\n self.set_secure_cookie('access', json.dumps(access))\n self.redirect('/')\n else:\n yield self.authorize_redirect(\n redirect_uri=REDIRECT_URI,\n client_id=self.settings[self._OAUTH_SETTINGS_KEY]['client_id'],\n scope=['profile'],\n response_type='code')\n\nclass IndexHandler(tornado.web.RequestHandler, NCTUOAuth2Mixin):\n @tornado.gen.coroutine\n def get(self):\n if self.get_secure_cookie('access'):\n access = json.loads(self.get_secure_cookie('access').decode())\n try:\n profile = yield self.oauth2_request(\n self._OAUTH_PROFILE_URL,\n access=access)\n self.finish(json.dumps(profile))\n except:\n self.redirect('/auth/')\n else:\n self.redirect('/auth/')\n\n\nif __name__ == '__main__':\n app = tornado.web.Application([\n ('/', IndexHandler),\n ('/auth/', OAuthHandler),\n ], \n debug=True,\n cookie_secret='secret!',\n NCTU_OAuth2={\n 'client_id': CLIENT_ID,\n 'client_secret': CLIENT_SECRET})\n app.listen(8080)\n tornado.ioloop.IOLoop().instance().start()\n```", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/allenwhale/NCTU-OAuth", "keywords": "python tornado nctu oauth nctu-oauth", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "tornado-NCTU-OAuth", "package_url": "https://pypi.org/project/tornado-NCTU-OAuth/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/tornado-NCTU-OAuth/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/allenwhale/NCTU-OAuth" }, "release_url": "https://pypi.org/project/tornado-NCTU-OAuth/0.1.2/", "requires_dist": null, "requires_python": null, "summary": "adds NCTU-OAuth support to tornado", "version": "0.1.2" }, "last_serial": 2323779, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "7a1c9e94127865fa95f98dc78b6d9520", "sha256": "c43db55b104d5a1dae023de62512aad5802e9f45af9331a6d0a9ce024727aae0" }, "downloads": -1, "filename": "tornado-NCTU-OAuth-0.1.1.tar.gz", "has_sig": false, "md5_digest": "7a1c9e94127865fa95f98dc78b6d9520", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2608, "upload_time": "2016-09-04T08:18:15", "url": "https://files.pythonhosted.org/packages/a5/21/426278b28694559697c888faa81c3c1051dfe755a4d257008fdc6f322a78/tornado-NCTU-OAuth-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "597c3bb0e428118b0d1734ac700a395c", "sha256": "26f82dd645ee953130797a37fa5699818b0c4af1af72685b589c030dcfbada57" }, "downloads": -1, "filename": "tornado-NCTU-OAuth-0.1.2.tar.gz", "has_sig": false, "md5_digest": "597c3bb0e428118b0d1734ac700a395c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2637, "upload_time": "2016-09-04T08:27:00", "url": "https://files.pythonhosted.org/packages/c9/d6/c226e4ad504456209be328c8376a1eff8f11167e51934ee97b4a4154ef02/tornado-NCTU-OAuth-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "597c3bb0e428118b0d1734ac700a395c", "sha256": "26f82dd645ee953130797a37fa5699818b0c4af1af72685b589c030dcfbada57" }, "downloads": -1, "filename": "tornado-NCTU-OAuth-0.1.2.tar.gz", "has_sig": false, "md5_digest": "597c3bb0e428118b0d1734ac700a395c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2637, "upload_time": "2016-09-04T08:27:00", "url": "https://files.pythonhosted.org/packages/c9/d6/c226e4ad504456209be328c8376a1eff8f11167e51934ee97b4a4154ef02/tornado-NCTU-OAuth-0.1.2.tar.gz" } ] }