def access_scopes(oauth_client: orm.OAuthClient, db: Session):
    """Return scope(s) required to access an oauth client
    This is a clone of `scopes.access_scopes` without using
    the `orm.Service`
    """
    scopes = set()
    if oauth_client.identifier == "jupyterhub":
        return frozenset()
    spawner = oauth_client.spawner
    if spawner:
        scopes.add(f"access:servers!server={spawner.user.name}/{spawner.name}")
    else:
        statement = "SELECT * FROM services WHERE oauth_client_id = :identifier"
        service = db.execute(
            text(statement), {"identifier": oauth_client.identifier}
        ).fetchall()
        if len(service) > 0:
            scopes.add(f"access:services!service={service[0].name}")

    return frozenset(scopes)
Return scope(s) required to access an oauth client
This is a clone of `scopes.access_scopes` without using
the `orm.Service`
jupyterhub/alembic/versions/651f5419b74d_api_token_scopes.py