# -*- coding: utf-8 -*-
from setuptools import setup

package_dir = \
{'': 'src'}

packages = \
['loctocat']

package_data = \
{'': ['*']}

install_requires = \
['aiohttp>=3.8.3,<4.0.0',
 'halo>=0.0.31,<0.0.32',
 'oauthlib>=3.2.2,<4.0.0',
 'requests>=2.28.1,<3.0.0',
 'termcolor>=2.1.1,<3.0.0']

setup_kwargs = {
    'name': 'loctocat',
    'version': '1.0.2',
    'description': 'Simple yet flexible OAuth 2.0 device flow authentication for Python',
    'long_description': '# loctocat\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/loctocat?logo=pypi&logoColor=white&style=for-the-badge)](https://pypi.org/project/loctocat)\n[![PyPI](https://img.shields.io/pypi/v/loctocat?color=green&logo=pypi&style=for-the-badge&logoColor=white)](https://pypi.org/project/loctocat)\n[![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/celsiusnarhwal/loctocat?color=orange&include_prereleases&label=latest%20release&logo=github&style=for-the-badge)](https://github.com/celsiusnarhwal/loctocat/releases/latest)\n[![PyPI - License](https://img.shields.io/pypi/l/loctocat?color=03cb98&style=for-the-badge)](https://github.com/celsiusnarhwal/loctocat/blob/HEAD/LICENSE.md)\n\nloctocat brings simple yet flexible OAuth 2.0 device flow authentication to Python. It has built-in asyncio support\nand even predefined authenticators for popular services. Plus, it\'s fully compliant with\n[RFC 8628](https://tools.ietf.org/html/rfc8628), making it compatible with any OAuth2-supporting service that\n(correctly) implements the standard.\n\n## Installation\n\n```bash\npip install loctocat\n```\n\n## Basic Usage\n\n### The `Authenticator` Class\n\nEvery authentication flow starts with loctocat\'s `Authenticator` class.\n\n```python\nfrom loctocat import Authenticator\n\nauthenticator = Authenticator(\n    client_id="your_client_id",\n    auth_url="https://example.com/oauth2/authorize",\n    token_url="https://example.com/oauth2/token",\n    scopes=["list", "of", "scopes"],\n)\n```\n\nIt\'s pretty simple — just instantiate the class with your client ID, authorization URL (where you\'ll get your device\nand user codes), token URL (where you\'ll poll the authorization server for an access token), and a list of any scopes\nyou need.\n\nOnce you\'ve got an `Authenticator`, getting an access token is as simple as:\n\n```python\ntoken = authenticator.authenticate()\n```\n\nWhoa. That was easy.\n\n`Authenticator.authenticate()` will, in order:\n\n1. Obtain device and user codes from the authorization server\n2. Prompt the user to visit the verficiation URL and enter the user code\n3. Poll the authorization server for an access token\n4. Return the access token as a string\n\nHere\'s an example of using `Authenticator` to authenticate with GitHub:\n\n```python\n# https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#device-flow\n\nfrom loctocat import Authenticator\n\nauthenticator = Authenticator(\n    client_id="github_client_id",  # Replace this with your app\'s actual client ID, obviously.\n    auth_url="https://github.com/login/device/code",\n    token_url="https://github.com/login/oauth/access_token",\n    scopes=["repo"],  # https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps\n)\n\ntoken = authenticator.authenticate()\n```\n\nLike I said, easy. Unless you\'re building an asynchronous application, in which case this doesn\'t work at all, since\n`Authenticator.authenticate()` is a blocking call. Fortunately, loctocat has you covered.\n\n### The `AsyncAuthenticator` Class\n\n`AsyncAuthenticator` is a subclass of `Authenticator` that functions exactly the same except all its methods are\nasynchronous (and therefore must be called with `await`). Here\'s an example of `AsyncAuthenticator` in action:\n\n```python\nfrom loctocat import AsyncAuthenticator\n\nauthenticator = AsyncAuthenticator(\n    client_id="your_client_id",\n    auth_url="https://example.com/oauth2/authorize",\n    token_url="https://example.com/oauth2/token",\n    scopes=["list", "of", "scopes"],\n)\n\ntoken = await authenticator.authenticate()\n```\n\nWhoa. That was easy.\n\n`AsyncAuthenticator.authenticate()` will, in or—wait, I\'m getting déjà vu.\n\n## Advanced Usage\n\nMaybe `Authenticator.authenticate()` is too simplistic for you. Maybe you\'d rather, I don\'t know,\nhandle the user-facing authentication prompt yourself, or control when loctocat starts polling for access tokens.\nFortunately, locotcat has you covered.\n\n(Keep in mind that `AsyncAuthenticator` is a subclass of `Authenticator` and inherits all of its methods and\nattributes.)\n\n### `Authenticator.ping()`\n\n`Authenticator.ping()` requests device and user codes from the authorization server, returning a `LoctocatAuthInfo`\nobject that looks like this:\n\n```py\nclass LoctocatAuthInfo:\n    device_code: str\n    user_code: str\n    verification_uri: str\n    expires_in: int\n    interval: int\n```\n\nPretty self-explanatory. You can do whatever you want with this information (aside from change it\n— `LoctocatAuthInfo`\'s attributes are read-only). For example, you could prompt the user with some custom text\ncontaining the user code and verification URI:\n\n```python\nauth_info = authenticator.ping()\n\nprint(f"Check it out, yo! This is some epic text telling YOU to go {auth_info.verification_uri} and enter {auth_info.user_code}! Swag!")\n```\n\n### `Authenticator.poll()`\n\n`Authenticator.poll()` polls the authorization server for an access token, returning it as a string. You **don\'t**\nneed to pass the `LoctocatAuthInfo` object returned by `Authenticator.ping()` to `Authenticator.poll()` — the\nauthorization info is automatically remembered by `Authenticator`. All you have to do is call the method:\n\n```python\n# Authenticator.ping() must have been called on the Authenticator object already or this will not work.\n\ntoken = authenticator.poll()\n```\n\nWhoa. That was easy.\n\n(Fun fact: `Authenticator.authenticate()` is just a wrapper around `ping()` and `poll()`.)\n\n## Pro Usage\n\nMaybe [Advanced Usage](#advanced-usage) isn\'t advanced enough for you. Maybe you\'re working with an authorization\nserver that requires parameters beyond those defined by `Authenticator`. Maybe you want to customize the prompts and\nmessages displayed by `Authenticator.authenticate()` without having to use `Authenticator.ping()` and\n`Authenticator.poll()`. Maybe loctocat has a predefined authenticator for a service you like, and you want to use it.\nUnfortunately, loctocat doesn\'t have you covered.\n\n...\n\nOkay, loctocat actually does have you covered, but that stuff is the domain of loctocat\'s unfinished documentation\nsite. Emphasis on unfinished. It\'s not finished yet.\n\nFortunately, loctocat has you covered. loctocat\'s a pretty small library and it\'s public modules and classes are all\nproperly documented in the source code, so you\'re welcome to learn by example(?) and take a look around.\n\nOr you could wait until I finish the documentation site. I\'m not your mother.\n\n## FAQ\n\nMaybe you have questions about loctocat that haven\'t been answered by the rest of this README. Maybe you just want to see me talk to\nmyself for like, two paragraphs. Fortunately, loctocat has you covered.\n\n### Q: loctowhat now\n\nA: Lock + [Octocat](https://octodex.github.com). loctocat was born out of my need for a Python library that implemented\nOAuth 2.0 device flow authentication for GitHub.\n\n### Q: I can just do this with requests-oauthlib or [INSERT OAUTH LIBRARY HERE] and those are like wayyyy more popular and tested so ummmm owned much?\n\nA: Ratio.\n\n### Q: loctocat isn\'t working with [INSERT SERVICE HERE] and I\'m FRUSTRATED AAAAGGGGGGHHHHH\n\nA: loctocat is compliant with the OAuth 2.0 Device Authorization Grant standard so it\'s probably the service\'s fault.\nMake sure the service actually does support the device flow and is generally compliant with RFC 8628. If you\'re sure\nloctocat is the problem, [open an issue](https://github.com/celsiusnarhwal/loctocat/issues/new).\n\n### Q: oh my god thank you I\'ve been looking for a library like this forever you have no idea\n\nA: You\'re very welcome. 🙂\n\n## License\n\nIn an age where developers must take great caution not to tread on the intellectual property of others, you must be\nhoping that a such an incredible library is made available under a permissive license. Fortunately,\nloctocat has you covered.\n\nloctocat is licensed under the [MIT License](https://github.com/celsiusnarhwal/loctocat/blob/HEAD/LICENSE.md).\n',
    'author': 'celsius narhwal',
    'author_email': 'hello@celsiusnarhwal.dev',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'https://github.com/celsiusnarhwal/loctocat',
    'package_dir': package_dir,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
