Source code for mirrorworld.mapillary.util

# Mirrorworld addition (not in upstream streetlevel).
import os

TOKEN_ENV_VAR = "MAPILLARY_ACCESS_TOKEN"






[docs] def get_access_token(access_token: str = None) -> str: """ Returns the access token to use for Mapillary requests: the one passed in, or else the ``MAPILLARY_ACCESS_TOKEN`` environment variable. Tokens (``MLY|...``) are free from https://www.mapillary.com/dashboard/developers. :param access_token: *(optional)* An explicit token. :return: The token. """ token = access_token or os.environ.get(TOKEN_ENV_VAR) if not token: raise ValueError(f"Mapillary requires an access token: pass access_token= or set {TOKEN_ENV_VAR}") return token