def first_authentication(api_key, secret):
    if (not is_authenticated(api_key)):
        with authentication_lock:
            if (not is_authenticated(api_key)):
                response = _request_access_token_with_retries(api_key, secret)
                API_KEYS_TO_TOKEN_DATA[api_key] = response.json()
                _set_api_key_authentication_status(api_key, response.ok)
                _calculate_and_set_time_to_refresh(api_key)
    if (not is_authenticated(api_key)):
        return _handle_authentications_error(f"Mona's client could not authenticate. errors: {_get_error_string_from_token_info(api_key)}")
    else:
        get_logger().info(f'New client token info: {API_KEYS_TO_TOKEN_DATA[api_key]}')
        return True
def first_authentication(api_key, secret):
    if (not is_authenticated(api_key)):
        with authentication_lock:
            if (not is_authenticated(api_key)):
                response = _request_access_token_with_retries(api_key, secret)
                API_KEYS_TO_TOKEN_DATA[api_key] = response.json()
                _set_api_key_authentication_status(api_key, response.ok)
                _calculate_and_set_time_to_refresh(api_key)
    if (not is_authenticated(api_key)):
        return _handle_authentications_error(f"Mona's client could not authenticate. errors: {_get_error_string_from_token_info(api_key)}")
    else:
        get_logger().info(f'New client token info: {API_KEYS_TO_TOKEN_DATA[api_key]}')
        return True