in remote_settings/client.py [0:0]
def _retrieve_remote_settings_bearer_token():
"""
Attempts to retrieve a Remote Settings bearer token exported to an environment
variable called REMOTE_SETTINGS_BEARER_TOKEN.
Exits with failure if the token cannot be retrieved.
Returns:
String: The bearer token.
"""
token = os.environ.get(REMOTE_SETTINGS_BEARER_TOKEN)
if token is None:
print_error(f"Failed to retrieve {REMOTE_SETTINGS_BEARER_TOKEN}")
print_help(BEARER_TOKEN_HELP_MESSAGE)
sys.exit(1)
# When copying the Remote Settings token from the UI, it copies in the format
# "Bearer <token>". We want to strip just the token if the user did not strip
# it already themselves.
if token.startswith("Bearer "):
return token[len("Bearer ") :]
return token