def access_scopes(oauth_client=None, *, spawner=None, service=None):
    """Return scope(s) required to access an oauth client"""
    scopes = set()
    if oauth_client and oauth_client.identifier == "jupyterhub":
        return frozenset()
    if spawner is None and oauth_client:
        spawner = oauth_client.spawner
    if spawner:
        scopes.add(f"access:servers!server={spawner.user.name}/{spawner.name}")
    else:
        if service is None:
            service = oauth_client.service
        if service:
            scopes.add(f"access:services!service={service.name}")
        else:
            app_log.warning(
                f"OAuth client {oauth_client} has no associated service or spawner!"
            )
    return frozenset(scopes)
Return scope(s) required to access an oauth client
jupyterhub/scopes.py