parameters: (cli_option: str = None)
return_statement: return token
docstring: Get the API token from a variety of fallback sources
docstring_summary: Get the API token from a variety of fallback sources
docstring_tokens: Get the API token from a variety of fallback sources
function: def get_access_token(cli_option: str = None) -> str:
      """Get the API token from a variety of fallback sources"""
  
      file_loc = pathlib.Path("~/.hmatoken").expanduser()
      environment_var = "HMA_TOKEN"
      token = ""
      if cli_option:
          token = cli_option
      elif os.environ.get(environment_var):
          token = os.environ[environment_var]
      elif file_loc.exists() and file_loc.read_text():
          token = file_loc.read_text()
      else:
          raise base.CommandError(
              (
                  "Can't find Access Token, pass it in using one of: \n"
                  "  * a cli argument (-a)\n"
                  f"  * in the environment as {environment_var}\n"
                  f"  * in a file at {file_loc}\n"
              ),
              2,
          )
      token = token.strip()
      return token
function_tokens: def get_access_token ( cli_option : str = None ) -> str : file_loc = pathlib . Path ( "~/.hmatoken" ) . expanduser ( ) environment_var = "HMA_TOKEN" token = "" if cli_option : token = cli_option elif os . environ . get ( environment_var ) : token = os . environ [ environment_var ] elif file_loc . exists ( ) and file_loc . read_text ( ) : token = file_loc . read_text ( ) else : raise base . CommandError ( ( "Can't find Access Token, pass it in using one of: \n" "  * a cli argument (-a)\n" f"  * in the environment as {environment_var}\n" f"  * in a file at {file_loc}\n" ) , 2 , ) token = token . strip ( ) return token