Metadata-Version: 2.1
Name: mad-oauth2
Version: 0.3.1
Summary: A Django app extension of django-oauth-toolkit that implements scope based applications.
Home-page: https://www.madithouse.com/
Author: Haseeb Ur Rehman
Author-email: haseeb@madithouse.com
License: Other/Proprietary License
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.1
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENCE.md

# Mad Oauth2

Mad Oauth2 app is an extention of django-oauth-toolkit that implements scopes and schemes in detail

## Quick start

1. Add "mad_oaut2" to your INSTALLED_APPS setting like this:

    ```python
    INSTALLED_APPS = [
        ...
        'oauth2_provider',
        'mad_oauth2',
        ...
    ]

    REST_FRAMEWORK = {
        ...
        "DEFAULT_PERMISSION_CLASSES": (
            "oauth2_provider.contrib.rest_framework.TokenMatchesOASRequirements",
            # OR
            "oauth2_provider.contrib.rest_framework.TokenHasResourceScope",
        ),
        ...
    }

    OAUTH2_PROVIDER_APPLICATION_MODEL="mad_oauth2.Application"
    OAUTH2_PROVIDER = {
        "SCOPES_BACKEND_CLASS": "mad_oauth2.oauth2.ApplicationScopes"
        "APPLICATION_ADMIN_CLASS": "mad_oauth2.admin.ApplicationAdminClass",
    }
    ```

2. Run ``python manage.py migrate`` to create mad_oauth2 models.

## Clearing Expired Tokens

Run celery periodic task to clear expired tokens
`mad_oauth2.tasks.removeExpiredTokens`

## Restricting Views with Scopes

Visit the official documentation for `django-oauth-toolkit` for more details on this:

https://django-oauth-toolkit.readthedocs.io/en/latest/rest-framework/permissions.html

## Throttling Requests

Visit the official documentation for `djangorestframework` for more details this:

https://www.django-rest-framework.org/api-guide/throttling/#scopedratethrottle


