{ "info": { "author": "Konstantin Togoi", "author_email": "konstantin.togoi@protonmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# ok.ru Python REST API wrapper\n\n- [About](#about)\n- [Getting Started](#getting-started)\n + [ImplicitSession](#implicitsession)\n + [TokenSession](#tokensession)\n + [Executing API requests](#executing-api-requests)\n - [Client-Server signature circuit](#client-server-circuit)\n - [Server-Server signature circuit](#sever-server-circuit)\n- [License](#license)\n\n\n## About\n\nThis is [ok.ru](https://ok.ru) (Russian social network) python API wrapper.\nThe goal is to support all API methods: https://apiok.ru/en/dev/methods/rest.\n\n## Getting Started\n\nInstall package using pip\n\n```bash\npip install aiookru\n```\n\nTo use OK API you need a registered app and account in the social network.\n\n1. Sign up in [ok.ru](https://ok.ru)\n2. Create **external** application.\n3. Save **App ID**, **App key**, **App secret key**.\n4. Use App ID, list of required permissions and user credentials to get **access token**.\n5. Use the access token to make method requests.\n\nAfter signing up go to https://apiok.ru/en/dev/app/create and create application.\n\n```python\napp_id = 'app ID'\napp_key = 'app key'\napp_secret_key = 'app secret'\n```\n\n### ImplicitSession\n\nYou can authenticate with [OK API OAuth](https://apiok.ru/en/ext/oauth/) by passing user credentials and permissions to `ImplicitSession` (or `ImplicitClientSession`/\n`ImplicitServerSession`).\n\n```python\nfrom aiookru.sessions import ImplicitSession\n\nphone = '+1999123456'\npassword = 'user password'\n\nsession = await ImplicitSession(\n app_id=app_id,\n app_key=app_key,\n app_secret_key=app_secret_key,\n login=phone,\n passwd=password,\n permissions='VALUABLE_ACCESS',\n)\n```\n\nNow you can execute API requests (see [Executing API requests](#executing-api-requests)).\nAfter authentication you will get access token **session.access_token** and\nsession secret key **session.session_secret_key**. Save them to make requests later:\n\n```python\naccess_token = session.access_token\nsession_secret_key = session.session_secret_key\n```\n\n### TokenSession\n\nIf you already have either of two:\n\n- `app_secret_key` and `access_token`\n- `session_secret_key`\n\n```python\nfrom aiookru.sessions import TokenSession\n\nsession = TokenSession(\n app_key=app_key,\n app_secret_key=app_secret_key,\n access_token=access_token,\n session_secret_key=session_secret_key,\n)\n```\n\nyou can instantiate `TokenSession` (or `ClinentSession`/`ServerSession`) and execute requests.\n\n\n### Executing API requests\n\n```python\nfrom aiookru import API\n\napi = API(session)\n\n# current user's friends\nfriends = await api.friends.get()\n```\n\nUnder the hood each API requests is encriched with:\n\n- `application_key`\n- `sig`\n- `app_secret_key` and `access_token` or `session_secret_key` \n- `format`\n- `method`\n\nBy default, the sessions try to infer which signature circuit to use:\n\n- if `app_secret_key` and `access_token` are not empty strings - server-server signature circuit is used\n- else if `session_secret_key` is not empty string - client-server signature circuit is used\n- else exception is raised\n\nYou can explicitly choose a circuit for signing requests by passing to `API` one\nof the following sessions:\n\n#### Sever-Server circuit\n\n```python\nfrom aiookru import ImplicitServerSession, API\nsession = await ImplicitServerSession(app_id, app_key, app_secret_key, phone, password)\napi = API(session)\n```\n\nor if you already have an access token\n\n```python\nfrom aiookru import ServerSession, API\nsession = ServerSession(app_key, app_secret_key, access_token)\n```\n\n#### Client-Server circuit\n\n```python\nfrom aiookru import ImplicitClientSession, API\nsession = await ImplicitClientSession(app_id, app_key, phone, password)\napi = API(session)\n```\n\nor if you already have a session secret key\n\n```python\nfrom aiookru import ClientSession, API\nsession = await ClientSession(app_key, session_secret_key)\napi = API(session)\n```\n\n## License\n\n**aiookru** is released under the BSD 2-Clause License.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/KonstantinTogoi/aiookru", "keywords": "ok.ru api asyncio", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "aiookru", "package_url": "https://pypi.org/project/aiookru/", "platform": "", "project_url": "https://pypi.org/project/aiookru/", "project_urls": { "Homepage": "https://github.com/KonstantinTogoi/aiookru" }, "release_url": "https://pypi.org/project/aiookru/0.0.1/", "requires_dist": [ "aiohttp (>=3.0.0)" ], "requires_python": "", "summary": "ok.ru Python REST API wrapper", "version": "0.0.1" }, "last_serial": 5728080, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "78867fcbf0f4b71ffd00e4353fe820e5", "sha256": "f170079b62530e946b65eb2edfcfc7e04ecf2dc7360fd55782b946d6e08370bb" }, "downloads": -1, "filename": "aiookru-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "78867fcbf0f4b71ffd00e4353fe820e5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8485, "upload_time": "2019-08-25T21:49:39", "url": "https://files.pythonhosted.org/packages/20/7a/2841c3cb2a5d39788e734394188d6bc308a8c48ef991f4f6e8490b7bca4a/aiookru-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8966deb867a7cf7af9c9671d1edcabb1", "sha256": "62405cddc15cc7cc9cde51a991e392e84ff385527d085a3d355ac4445dcb53d0" }, "downloads": -1, "filename": "aiookru-0.0.1.tar.gz", "has_sig": false, "md5_digest": "8966deb867a7cf7af9c9671d1edcabb1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7297, "upload_time": "2019-08-25T21:49:42", "url": "https://files.pythonhosted.org/packages/1c/de/cc5e0af25ea6fdff868127b876ed8e14f72e7c05cf308af113b1dd236c8d/aiookru-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "78867fcbf0f4b71ffd00e4353fe820e5", "sha256": "f170079b62530e946b65eb2edfcfc7e04ecf2dc7360fd55782b946d6e08370bb" }, "downloads": -1, "filename": "aiookru-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "78867fcbf0f4b71ffd00e4353fe820e5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8485, "upload_time": "2019-08-25T21:49:39", "url": "https://files.pythonhosted.org/packages/20/7a/2841c3cb2a5d39788e734394188d6bc308a8c48ef991f4f6e8490b7bca4a/aiookru-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8966deb867a7cf7af9c9671d1edcabb1", "sha256": "62405cddc15cc7cc9cde51a991e392e84ff385527d085a3d355ac4445dcb53d0" }, "downloads": -1, "filename": "aiookru-0.0.1.tar.gz", "has_sig": false, "md5_digest": "8966deb867a7cf7af9c9671d1edcabb1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7297, "upload_time": "2019-08-25T21:49:42", "url": "https://files.pythonhosted.org/packages/1c/de/cc5e0af25ea6fdff868127b876ed8e14f72e7c05cf308af113b1dd236c8d/aiookru-0.0.1.tar.gz" } ] }