<commit_before>from django.conf import settings
from django.http import HttpResponse
from authz_group import Group
from blti.views.rest_dispatch import RESTDispatch as BLTIRESTDispatch
from blti.views.rest_dispatch import RESTDispatchAuthorization
import simplejson as json


class RESTDispatch(BLTIRESTDispatch):
    """ Handles passing on the request to the correct view method
        based on the request type.
    """
    def authorize(self, request):
        try:
            self.blti_authorize(request)
        except RESTDispatchAuthorization:
            if (not (request.user.is_authenticated() and
                     Group().is_member_of_group(
                         request.user.username,
                         settings.PANOPTO_ADMIN_GROUP))):
                raise<commit_msg>adds oauth api validation<commit_after>from django.conf import settings
from django.http import HttpResponse
from authz_group import Group
from blti import BLTI, BLTIException
from blti.views.rest_dispatch import RESTDispatch as BLTIRESTDispatch
from blti.views.rest_dispatch import RESTDispatchAuthorization
import simplejson as json


class RESTDispatch(BLTIRESTDispatch):
    """ Handles passing on the request to the correct view method
        based on the request type.
    """
    def authorize(self, request):
        try:
            self.blti_authorize(request)
        except RESTDispatchAuthorization:
            try:
                BLTI().oauth_validate(request)
            except BLTIException:
                if (request.user.is_authenticated() and
                    Group().is_member_of_group(
                        request.user.username,
                        settings.PANOPTO_ADMIN_GROUP)):
                    return

                raise RESTDispatchAuthorization("Access Denied")
{'fraction_non_alphanumeric': 0.05638474295190713, 'fraction_numerical': 0.0, 'mean_word_length': 2.467432950191571, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1342732', 'n_tokens_mistral': 459, 'n_tokens_neox': 432, 'n_words': 129}