{ "info": { "author": "Artem Gnilov", "author_email": "boobsd@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "===========\r\nFlask-oDesk\r\n===========\r\n\r\nRequirements\r\n============\r\n\r\n * `flask`\r\n * `python-odesk`\r\n * `python-oauth2`\r\n\r\n\r\nAuthorization\r\n==============\r\n\r\nQuick start\r\n-----------\r\n\r\nBefore you may use oDesk APIs, you will need to obtain your pair of API keys.\r\nVisit the `oDesk API Center documentation `_\r\nfor full details. Please note, that Flask-oDesk uses authorization via OAuth and it needs keys with auth type \"OAuth\".\r\n\r\nPlease make sure, that `SECRET_KEY` which is necessary for sessions, based on the secure cookies, is indicated in `settings.py`::\r\n\r\n SECRET_KEY = '(your random secret key)'\r\n\r\nYou need to store your pair of oDesk API keys in `settings.py`::\r\n\r\n ODESK_KEY = '(your oDesk public key)'\r\n ODESK_SECRET = '(your oDesk secret key)'\r\n\r\nYou can also set the list of teams in `settings.py`, which will be able to authorize.\r\nIf you do not specify this option or leave the list empty, then all oDesk users will be able to authorize::\r\n\r\n\r\n ODESK_AUTH_TEAMS = ('odesk:odeskpsbootcamp',)\r\n\r\nPlease make sure, that you have registered odesk module in your `app.py` correctly.\r\nPlease keep in mind, that `url_prefix` can be whatever you like::\r\n\r\n from flask import Flask\r\n from flaskext.odesk import odesk\r\n\r\n app = Flask(__name__)\r\n app.config.from_pyfile('settings.py')\r\n app.register_module(odesk, url_prefix='/odesk')\r\n\r\n\r\n\r\nUsing authorization\r\n-------------------\r\n\r\nPlease use the decorator `login_required` to close the access for anonymous users to the certain parts of your website::\r\n\r\n @app.route('/only/for/odesk/users')\r\n @odesk.login_required\r\n def admin():\r\n return \"Welcome, oDesk user!\"\r\n\r\nIf you want to indicate login or logout links in the template, than you can use `url_for` function and `odesk_is_authorized` variable::\r\n\r\n {% if odesk_is_authorized %}\r\n Log out\r\n {% else %}\r\n oDesk log in\r\n {% endif %}\r\n\r\nTo check the authorization of the current user you can use `is_authorized` method::\r\n\r\n @app.route('/test')\r\n def test():\r\n if odesk.is_authorized():\r\n return \"You are authorized.\"\r\n else:\r\n return \"You are not authorized yet.\"\r\n\r\nIf you need, you can start the authorization process manually from your code::\r\n\r\n if not odesk.is_authorized():\r\n return odesk.login()\r\n\r\nYou can also use `next` parameter to indicate URL, where will be redirect after the authorization process ends::\r\n\r\n if not odesk.is_authorized():\r\n return odesk.login(next='/blah/blah')\r\n\r\nYou can use `logout` method for user's logging out.\r\nPlease pay attention, that unlike `login` this method do not return the bulk of redirects.\r\nIt simply deletes the OAuth session. You should return response manually::\r\n\r\n if odesk.is_authorized():\r\n odesk.logout()\r\n return redirect('/')\r\n\r\nIf you want to expand autorization process, you can use `after_login` decorator,\r\nthat indicates your function, which will be called after successfully authorization::\r\n\r\n @odesk.after_login\r\n def save_session():\r\n # Getting current user's data. Please, see below how to use the Client.\r\n session['user'] = odesk.get_client().hr.get_user('me')\r\n\r\nIf you have used `after_login` and saved something to the session, please,\r\ndo not forget to delete this session after logging out, using decorator `after_logout`::\r\n\r\n @odesk.after_logout\r\n def delete_session():\r\n if 'user' in session:\r\n del session['user']\r\n\r\n\r\nUsing client\r\n============\r\n\r\nYou can use `get_access_token` method to get the current access token and access token secret,\r\nthat can be stored in DB and used for access to the client later, if necessary::\r\n\r\n if odesk.is_authorized():\r\n access_token, access_token_secret = odesk.get_access_token()\r\n\r\nYou can use `get_client` method to get the client::\r\n\r\n if odesk.is_authorized():\r\n c = odesk.get_client()\r\n c.team.get_teamrooms()\r\n\r\nOr you can use the client even if the current user is not authorized,\r\nbut you have the access token and access token secret::\r\n\r\n if not odesk.is_authorized():\r\n c = odesk.get_client(access_token, access_token_secret)\r\n c.team.get_teamrooms()", "description_content_type": null, "docs_url": null, "download_url": "http://github.com/odesk/flask-odesk", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/odesk/flask-odesk", "keywords": "", "license": "BSD", "maintainer": "Volodymyr Hotsyk", "maintainer_email": "gotsyk@gmail.com", "name": "Flask-oDesk", "package_url": "https://pypi.org/project/Flask-oDesk/", "platform": "any", "project_url": "https://pypi.org/project/Flask-oDesk/", "project_urls": { "Download": "http://github.com/odesk/flask-odesk", "Homepage": "https://github.com/odesk/flask-odesk" }, "release_url": "https://pypi.org/project/Flask-oDesk/0.4.1.1/", "requires_dist": null, "requires_python": null, "summary": "Adds oDesk API support to Flask", "version": "0.4.1.1" }, "last_serial": 752498, "releases": { "0.4.1.1": [ { "comment_text": "", "digests": { "md5": "e2581d230c3b8219b0f3d666cbe74e56", "sha256": "b5c02adc7fb1bb0b6d1cc79085a43bfb093b930ba5f5a98cd8abbd4f862d57fb" }, "downloads": -1, "filename": "Flask-oDesk-0.4.1.1.tar.gz", "has_sig": false, "md5_digest": "e2581d230c3b8219b0f3d666cbe74e56", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5730, "upload_time": "2011-06-20T13:17:43", "url": "https://files.pythonhosted.org/packages/7b/af/ab6d56d13b8024fcd37850973c73d008ac1eb6ad109fe849b57997e2dde0/Flask-oDesk-0.4.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e2581d230c3b8219b0f3d666cbe74e56", "sha256": "b5c02adc7fb1bb0b6d1cc79085a43bfb093b930ba5f5a98cd8abbd4f862d57fb" }, "downloads": -1, "filename": "Flask-oDesk-0.4.1.1.tar.gz", "has_sig": false, "md5_digest": "e2581d230c3b8219b0f3d666cbe74e56", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5730, "upload_time": "2011-06-20T13:17:43", "url": "https://files.pythonhosted.org/packages/7b/af/ab6d56d13b8024fcd37850973c73d008ac1eb6ad109fe849b57997e2dde0/Flask-oDesk-0.4.1.1.tar.gz" } ] }