'Raise an InvalidScopeError if key.scope is not in self._allowed_scopes.'

def _raise_unless_scope_is_allowed(self, key):

    if (key.scope not in self._allowed_scopes):
        raise InvalidScopeError(key, self._allowed_scopes)
