MCPcopy Create free account
hub / github.com/HumeAI/hume-api-examples / get_access_token

Function get_access_token

evi/evi-python-raw-api/src/main.py:74–102  ·  view source on GitHub ↗

Load API credentials from environment variables and fetch an access token. Returns: str: The access token. Raises: SystemExit: If API key or Secret key are not set.

()

Source from the content-addressed store, hash-verified

72
73
74def get_access_token() -> str:
75 """
76 Load API credentials from environment variables and fetch an access token.
77
78 Returns:
79 str: The access token.
80
81 Raises:
82 SystemExit: If API key or Secret key are not set.
83 """
84 load_dotenv()
85
86 # Attempt to retrieve API key and Secret key from environment variables
87 HUME_API_KEY = os.getenv("HUME_API_KEY")
88 HUME_SECRET_KEY = os.getenv("HUME_SECRET_KEY")
89
90 # Ensure API key and Secret key are set
91 if HUME_API_KEY is None or HUME_SECRET_KEY is None:
92 print(
93 "Error: HUME_API_KEY and HUME_SECRET_KEY must be set either in a .env file or as environment variables."
94 )
95 exit()
96
97 # Create an instance of Authenticator with the API key and Secret key
98 authenticator = Authenticator(HUME_API_KEY, HUME_SECRET_KEY)
99
100 # Fetch the access token
101 access_token = authenticator.fetch_access_token()
102 return access_token
103
104
105if __name__ == "__main__":

Callers 1

mainFunction · 0.70

Calls 2

fetch_access_tokenMethod · 0.95
AuthenticatorClass · 0.90

Tested by

no test coverage detected