def clean(self): """ Make sure that the scope is less or equal to the previous scope! """ data = self.cleaned_data if "scope" in data and not scope.check(data.get("scope"), data.get("refresh_token").access_token.scope): raise OAuthValidationError({"error": "invalid_scope"}) return data
def clean(self): """ Make sure that the scope is less or equal to the scope allowed on the grant! """ data = self.cleaned_data # Only check if we've actually got a scope in the data # (read: All fields have been cleaned) if "scope" in data and not scope.check(data.get("scope"), data.get("grant").scope): raise OAuthValidationError({"error": "invalid_scope"}) return data