<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_scope(self, token, request):
 http_method = request.method if not hasattr(self, http_method):
 raise OAuthError("HTTP method is not recognized") required_scopes = getattr(self, http_method) # a None scope means always allowed if required_scopes is None: return True """ The required scope is either a string or an iterable. If string, check if it is allowed for our access token otherwise, iterate through the required_scopes to see which scopes are allowed """

        # for non iterable types
        if isinstance(required_scopes, six.string_types):
            if token.allow_scopes(required_scopes.split()):
                return [required_scopes]
            return []
        allowed_scopes = []
        try:
            for scope in required_scopes:
                if token.allow_scopes(scope.split()):
                    allowed_scopes.append(scope)
        except:
            raise Exception('Invalid required scope values')
        else:
            return allowed_scopes