{ "info": { "author": "Rodrigo Cacilhas", "author_email": "rodrigo.cacilhas@nexaas.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "License :: Other/Proprietary License", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3 :: Only", "Topic :: Utilities" ], "description": "# Nexaas ID Client\n\nThis is a client for Nexaas ID. It brings support for generic OAuth\nauthentication and for Django and Flask frameworks.\n\n## OAuth client\n\nThe general use is:\n\n```python\nfrom nexaas_id_client import NexaasIDOAuthClient\n\nclient = NexaasIDOAuthClient(\n application_token,\n application_secret,\n server='id.nexaas.com',\n redirect_uri=application_callback,\n)\n```\n\nThe authorization URL can get from `client.authorize_url` and the access token\ncan be retrieve in the callback procedure from `client.get_access_token(code)`,\nwhere `code` is the access grant code.\n\n### Settings for Django and Flask\n\n- `NEXAAS_ID_CLIENT_ID`: the application token\n- `NEXAAS_ID_CLIENT_SECRET`: the application secret\n- `NEXAAS_ID_HOST`: the Nexaas ID host\n- `NEXAAS_ID_CLIENT_SCOPE`: the scope (can be `None`)\n\n### Django\n\nIn Django you must include the following path to the main `urlpatterns`:\n\n```python\n path('oauth/', include('nexaas_id_client.support.django.urls'))\n```\n\nThe views that requires authorized access must be decorated:\n\n```python\nfrom nexaas_id_client.support.django.decorators import authorization_required\n\n@authorization_required\ndef index(request, api_client: 'nexaas_id_client.NexaasIDClient') -> 'django.http.request.HttpResponse':\n\t...\n```\n\nYour view must expect an `api_client` as argument \u2013 see bellow. Anyway you can\nretrieve de access token from the session, under the key `oauth_access_token`.\n\nIn order to logout, use the app route `signout`. The query string key\n`next_url` inform where to redirect after sign out.\n\n**Caution:** If the view returns falsy (`None`, `False`, `0`, `\"\"`, et cetera),\nthe `authorization_required` decorator redirects to sign out URL.\n\n### Flask\n\nThe Flask support supplies a blueprint capable of deal with Nexaas ID OAuth.\n\nThe use:\n\n```python\nfrom flask import Flask\nfrom nexaas_id_client.support.flask import oauth\n\n\napp = Flask(__name__)\napp.register_blueprint(oauth, url_prefix='/oauth')\n```\n\nThe decorator is similar to Django support:\n\n```python\nfrom nexaas_id_client.support.flask import authorization_required, oauth\n...\n\n@app.route('/')\n@authorization_required\ndef index(api_client: 'nexaas_id_client.NexaasIDClient') -> 'flask.Response':\n ...\n```\n\nYour view must expect an `api_client` as argument \u2013 see bellow. Anyway you can\nretrieve de access token from the session, under the key `oauth_access_token`.\n\nIn order to logout, use the blueprint route `signout`. The query string key\n`next_url` inform where to redirect after sign out.\n\n## API client\n\nThe API client is responsible for dealing with Nexaas ID API.\n\nYou can get it this way:\n\n```python\napi_client = NexaasIDClient.from_oauth(\n client.get_access_token(code),\n client=client,\n)\n```\n\nWhere `client` is the OAuth client and `code` is the access grant code.\n\nBut, if you are using a framework support, you don\u2019t need to do it: views\ndecorated by `authorization_required` will receive an API client ready to use.\n\n### Resource API\n\nThe API client attributes:\n\n- `access_token: str` \u2013 the access token\n- `refresh_token: str` \u2013 the refresh token\n- `scope: str` \u2013 the allowed scope\n- `token: OAuthToken` \u2013 a token wrapper\n- `id: str` \u2013 the client id\n- `secret: str` \u2013 the client secret\n- `server: urllib.parse.ParseResult` \u2013 the Nexaas ID server\n- `personal_info: PersonalInfo` \u2013 the user\u2019s personal data\n- `professional_info: ProfessionalInfo` \u2013 the user\u2019s professional data\n- `emails: Emails` \u2013 a dictionary containing user id and the its e-mails list\n- `contacts: Contacts` \u2013 a dictionary containing user id and its phone numbers\n and eventually other contacts\n- `invite(email: str) -> Invitation` \u2013 invite another user to the current\n application\n\nThe classes `PersonalInfo`, `ProfessionalInfo`, `Emails`, `Contacts` and\n`Invitation` are built on demand metaprogrammatically, and have an `id`\nattribute (`uuid.UUID`) at least.\n\nOther attributes you may expect:\n\n- `PersonalInfo`\n - `full_name: str`\n - `first_name: str`\n - `last_name: str`\n - `nickname: str`\n - `email: str`\n - `birth: datetime.date`\n - `gender: str`\n - `language: str`\n - `picture: str`\n - `timezone: str`\n - `country: str`\n - `city: str`\n - `bio: str`\n\n- `ProfessionalInfo`\n - `profession: str`\n - `company: str`\n - `position: str`\n\n- `Emails`\n - `emails: List[str]`\n\n- `Contacts`:\n - `phone_numbers: List[str]`\n\n- `Invitation`:\n - `email` (invited user)\n - `requester` (inviter id)\n\n- `OAuthToken`:\n - `access_token: str`\n - `refresh_token: str`\n - `expired_at: datetime.datetime`\n - `scope: str`\n - `expired: bool` (maybe not present)\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/myfreecomm/nexaas-id-client-python", "keywords": "nexaas-id oauth", "license": "Proprietary License", "maintainer": "", "maintainer_email": "", "name": "nexaas-id-client", "package_url": "https://pypi.org/project/nexaas-id-client/", "platform": "", "project_url": "https://pypi.org/project/nexaas-id-client/", "project_urls": { "Homepage": "https://github.com/myfreecomm/nexaas-id-client-python" }, "release_url": "https://pypi.org/project/nexaas-id-client/1.0.1/", "requires_dist": [ "python-dateutil (>=2.7.0)", "requests (>=2.19.0)" ], "requires_python": "", "summary": "Nexaas ID Python client", "version": "1.0.1" }, "last_serial": 4227658, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "1ef6a28db3c53096f8a86a3e0da5a9b8", "sha256": "f6ec8ff062a364d98927318994065fc60c27bb4f749d2673db05c44a022bc288" }, "downloads": -1, "filename": "nexaas_id_client-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "1ef6a28db3c53096f8a86a3e0da5a9b8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9505, "upload_time": "2018-08-31T21:19:08", "url": "https://files.pythonhosted.org/packages/0c/e0/6d600a95c99ee2a648976293b13f6d5ecd5d6da3919dae0ae7cfcc2efdda/nexaas_id_client-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "023a25a912355a3dd9700d3cb996512d", "sha256": "c6e73c23c51c8a054550b54b618d54f4b860261a1ef57463e96c544878804550" }, "downloads": -1, "filename": "nexaas_id_client-1.0.tar.gz", "has_sig": false, "md5_digest": "023a25a912355a3dd9700d3cb996512d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5850, "upload_time": "2018-08-31T21:19:09", "url": "https://files.pythonhosted.org/packages/3d/3d/709f6446b64fdbe38a2ec37d13e6fe28f006133aaaa4211360df48ad0cd5/nexaas_id_client-1.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "403eb7ee8deaed8f43cb0b4221918ff5", "sha256": "232380f36a43139f788d8c0d48c0596ef4d60d60c44ef3fa54cb345567cd7812" }, "downloads": -1, "filename": "nexaas_id_client-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "403eb7ee8deaed8f43cb0b4221918ff5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11211, "upload_time": "2018-08-31T21:24:49", "url": "https://files.pythonhosted.org/packages/72/41/325af8921412eb2d8696208e64818c77af5ffe6ee8f75431848f763cd603/nexaas_id_client-1.0.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "403eb7ee8deaed8f43cb0b4221918ff5", "sha256": "232380f36a43139f788d8c0d48c0596ef4d60d60c44ef3fa54cb345567cd7812" }, "downloads": -1, "filename": "nexaas_id_client-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "403eb7ee8deaed8f43cb0b4221918ff5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11211, "upload_time": "2018-08-31T21:24:49", "url": "https://files.pythonhosted.org/packages/72/41/325af8921412eb2d8696208e64818c77af5ffe6ee8f75431848f763cd603/nexaas_id_client-1.0.1-py3-none-any.whl" } ] }