def identify_scopes(obj=None):
    """Return 'identify' scopes for an orm object

    Arguments:
      obj (optional): orm.User or orm.Service
          If not specified, 'raw' scopes for identifying the current user are returned,
          which may need to be expanded, later.

    Returns:
      identify scopes (set): set of scopes needed for 'identify' endpoints
    """
    if obj is None:
        return frozenset(f"read:users:{field}!user" for field in {"name", "groups"})
    elif isinstance(obj, orm.User):
        return frozenset(
            f"read:users:{field}!user={obj.name}" for field in {"name", "groups"}
        )
    elif isinstance(obj, orm.Service):
        return frozenset(
            f"read:services:{field}!service={obj.name}" for field in {"name"}
        )
    else:
        raise TypeError(f"Expected orm.User or orm.Service, got {obj!r}")
Return 'identify' scopes for an orm object

Arguments:
obj (optional): orm.User or orm.Service
If not specified, 'raw' scopes for identifying the current user are returned,
which may need to be expanded, later.

Returns:
identify scopes (set): set of scopes needed for 'identify' endpoints
jupyterhub/scopes.py